File tree 3 files changed +18
-20
lines changed
lib/redmine_git_hosting/gitolite_wrappers/global
3 files changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,23 @@ def rw_access_perms
32
32
[ permissions ]
33
33
end
34
34
35
+
36
+ def repo_conf
37
+ all_repository_config
38
+ end
39
+
40
+
41
+ def perms
42
+ repo_conf . permissions . select { |p | p . has_key? 'RW+' }
43
+ end
44
+
45
+
46
+ # RedmineGitHosting key can act on any refspec ('') so it should be in that 'subgroup'
47
+ #
48
+ def users
49
+ perms [ 0 ] [ 'RW+' ] [ '' ]
50
+ end
51
+
35
52
end
36
53
end
37
54
end
Original file line number Diff line number Diff line change @@ -19,17 +19,11 @@ def call
19
19
20
20
21
21
def remove_redmine_key
22
- repo_conf = all_repository_config
23
-
24
- # RedmineGitHosting key must be in RW+ group
25
- perms = repo_conf . permissions . select { |p | p . has_key? 'RW+' }
26
-
27
22
# RedmineGitHosting key must be in [RW+][''] group
28
23
# Return if those groups are absent : it means that our key is not here
29
24
return if perms . empty? || !perms [ 0 ] [ 'RW+' ] . include? ( '' )
30
25
31
26
# Check for key presence
32
- users = perms [ 0 ] [ 'RW+' ] [ '' ]
33
27
return if !users . include? ( redmine_gitolite_key )
34
28
35
29
# Delete the key
Original file line number Diff line number Diff line change @@ -22,30 +22,17 @@ def call
22
22
23
23
24
24
def add_redmine_key
25
- repo_conf = all_repository_config
26
-
27
25
# RedmineGitHosting key must be in RW+ group
28
- perms = repo_conf . permissions . select { |p | p . has_key? 'RW+' }
29
-
30
26
# If not create the RW+ group and add the key
31
27
if perms . empty?
32
28
logger . info ( "#{ context } : No permissions set for '@all' repository, add RedmineGitHosting key" )
33
29
repo_conf . permissions = rw_access_perms
34
- return
35
- end
36
-
37
- # RedmineGitHosting key can act on any refspec ('') so it should be it that 'subgroup'
38
- users = perms [ 0 ] [ 'RW+' ] [ '' ]
39
-
40
- # If not create it
41
- if users . nil?
30
+ elsif users . nil?
42
31
logger . info ( "#{ context } : RedmineGitHosting key is not present, add it !" )
43
32
repo_conf . permissions [ 0 ] [ 'RW+' ] [ '' ] = [ redmine_gitolite_key ]
44
- # Check that the 'subgroup' contains our key
45
33
elsif !users . include? ( redmine_gitolite_key )
46
34
logger . info ( "#{ context } : RedmineGitHosting key is not present, add it !" )
47
35
repo_conf . permissions [ 0 ] [ 'RW+' ] [ '' ] . push ( redmine_gitolite_key )
48
- # Our key already here, nothing to do
49
36
else
50
37
logger . info ( "#{ context } : RedmineGitHosting key is present, nothing to do." )
51
38
end
You can’t perform that action at this time.
0 commit comments