aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStevan Radaković <stevan.radakovic@linaro.org>2013-04-09 11:59:46 +0200
committerStevan Radaković <stevan.radakovic@linaro.org>2013-04-09 11:59:46 +0200
commita126053e500fca0be7e43b803ee9ac68fd03c426 (patch)
treef9270339c9185929c07d9f9896754aea031a50ec
parentdd4e6e802213f7f35b0a378358164461e7e98c22 (diff)
downloadrhodecode-repo_model_changes.tar.gz
Handle updates if system group does not exist.v1.5.4.1_linarorepo_model_changes
-rw-r--r--rhodecode/lib/system_command.py11
-rw-r--r--rhodecode/model/repo.py5
-rw-r--r--rhodecode/model/repos_group.py5
3 files changed, 21 insertions, 0 deletions
diff --git a/rhodecode/lib/system_command.py b/rhodecode/lib/system_command.py
index 14d25289..04d5d69c 100644
--- a/rhodecode/lib/system_command.py
+++ b/rhodecode/lib/system_command.py
@@ -75,3 +75,14 @@ class SystemCommand():
def change_ownership(cls, path, group):
cmd_args = ["change-repo-ownership", path, group]
cls.execute(cmd_args)
+
+ @classmethod
+ def get_system_groups(cls):
+ cmd_args = ["getent", "group"]
+ try:
+ output = cls.execute(cmd_args)
+ lines = output.split()
+ groups = [line.split(":")[0] for line in lines]
+ return groups
+ except:
+ return []
diff --git a/rhodecode/model/repo.py b/rhodecode/model/repo.py
index b228a5ac..7aa1514f 100644
--- a/rhodecode/model/repo.py
+++ b/rhodecode/model/repo.py
@@ -324,6 +324,11 @@ class RepoModel(BaseModel):
cur_repo.repo_id)
SystemCommand.rename_group(old_system_name, new_system_name)
+ if new_system_name not in SystemCommand.get_system_groups():
+ SystemCommand.add_group(new_system_name)
+ SystemCommand.change_ownership(cur_repo.repo_name,
+ new_system_name)
+
if org_repo_name != new_name:
# rename repository
self.__rename_repo(old=org_repo_name, new=new_name)
diff --git a/rhodecode/model/repos_group.py b/rhodecode/model/repos_group.py
index 625762f2..c3df1c1f 100644
--- a/rhodecode/model/repos_group.py
+++ b/rhodecode/model/repos_group.py
@@ -304,6 +304,11 @@ class ReposGroupModel(BaseModel):
repos_group.group_id)
SystemCommand.rename_group(old_system_name, new_system_name)
+ if new_system_name not in SystemCommand.get_system_groups():
+ SystemCommand.add_group(new_system_name)
+ SystemCommand.change_ownership(repos_group.group_name,
+ new_system_name)
+
return repos_group
except:
log.error(traceback.format_exc())