jbox-gitolite 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b2c9b563847ffc8bdca2044d65da8a8a8efcd2a
4
- data.tar.gz: 9c7e61206ac0aeae49440f6c41e0f5b776c1f453
3
+ metadata.gz: b8d77c8feb647bdec7c1f02c7fe17d0f784d2b65
4
+ data.tar.gz: 846058e42798a4a2e9d63216e40b4a91ede877ef
5
5
  SHA512:
6
- metadata.gz: 57785aa12ad576d43f83cda8d89ba37c064533d0265a4c476ac31853f0022bea6d8f291bc96ff43164d403cfd15d814249a047d3cb01c31e4b06660ec08cc5bb
7
- data.tar.gz: 1d7e3a63fdf86ab86da9d32addfcd4b9756124011f8c9343fbc592c91565991c3f2bcf55eab7c98960ef0b06d943c589aa9b236bb5a37d2d9b7a466dff120214
6
+ metadata.gz: 047899d17bb0346ee7f0f833e1ba04800ba96e1eb5c50e7aa536b388db7d7f4bf1114d28ba84e0ef4370df6e1adf19dc63f58a110967e67bf8b2b97792f5d6ba
7
+ data.tar.gz: e16d359aad89f8343ae2f0b472fcb688ddf9f8075c5a2ab41eb4ce274529c6d412c023024d61a8044f6a09a1f77b609b29c72694cbea6ba0b782abd5e8a44bcd
File without changes
File without changes
@@ -2,208 +2,240 @@ require File.join(File.dirname(__FILE__), "dirty_proxy")
2
2
 
3
3
  module Gitolite
4
4
  class GitoliteAdmin
5
+
5
6
  attr_accessor :gl_admin
6
7
 
7
- CONF = "gitolite.conf"
8
- CONFDIR = "conf"
9
- KEYDIR = "keydir"
10
- DEBUG = false
8
+ CONFIG_FILE = "gitolite.conf"
9
+ CONF_DIR = "conf"
10
+ KEY_DIR = "keydir"
11
+ DEBUG = false
12
+ TIMEOUT = 10
11
13
 
12
- #Gitolite gem's default git commit message
14
+ # Gitolite gem's default commit message
13
15
  DEFAULT_COMMIT_MSG = "Committed by the gitolite gem"
14
16
 
17
+ class << self
18
+
19
+ # Checks to see if the given path is a gitolite-admin repository
20
+ # A valid repository contains a conf folder, keydir folder,
21
+ # and a configuration file within the conf folder
22
+ def is_gitolite_admin_repo?(dir)
23
+ # First check if it is a git repository
24
+ begin
25
+ Grit::Repo.new(dir)
26
+ rescue Grit::NoSuchPathError, Grit::InvalidGitRepositoryError
27
+ return false
28
+ end
29
+
30
+ # If we got here it is a valid git repo,
31
+ # now check directory structure
32
+ File.exists?(File.join(dir, 'conf')) &&
33
+ File.exists?(File.join(dir, 'keydir')) &&
34
+ !Dir.glob(File.join(dir, 'conf', '*.conf')).empty?
35
+ end
36
+
37
+
38
+ # This method will bootstrap a gitolite-admin repo
39
+ # at the given path. A typical gitolite-admin
40
+ # repo will have the following tree:
41
+ #
42
+ # gitolite-admin
43
+ # conf
44
+ # gitolite.conf
45
+ # keydir
46
+ def bootstrap(path, options = {})
47
+ if self.is_gitolite_admin_repo?(path)
48
+ if options[:overwrite]
49
+ FileUtils.rm_rf(File.join(path, '*'))
50
+ else
51
+ return self.new(path)
52
+ end
53
+ end
54
+
55
+ FileUtils.mkdir_p([File.join(path, "conf"), File.join(path, "keydir")])
56
+
57
+ options[:perm] ||= "RW+"
58
+ options[:refex] ||= ""
59
+ options[:user] ||= "git"
60
+
61
+ c = Config.init
62
+ r = Config::Repo.new(options[:repo] || "gitolite-admin")
63
+ r.add_permission(options[:perm], options[:refex], options[:user])
64
+ c.add_repo(r)
65
+ config = c.to_file(File.join(path, "conf"))
66
+
67
+ gl_admin = Grit::Repo.init(path)
68
+ gl_admin.git.native(:add, {:chdir => gl_admin.working_dir}, config)
69
+ gl_admin.git.native(:commit, {:chdir => gl_admin.working_dir}, '-a', '-m', options[:message] || "Config bootstrapped by the gitolite gem")
70
+
71
+ self.new(path)
72
+ end
73
+
74
+ end
75
+
76
+
15
77
  # Intialize with the path to
16
78
  # the gitolite-admin repository
17
79
  def initialize(path, options = {})
18
80
  @path = path
19
- @gl_admin = Grit::Repo.new(path)
20
81
 
21
- @conf = options[:conf] || CONF
22
- @confdir = options[:confdir] || CONFDIR
23
- @keydir = options[:keydir] || KEYDIR
82
+ @config_file = options[:config_file] || CONFIG_FILE
83
+ @conf_dir = options[:conf_dir] || CONF_DIR
84
+ @key_dir = options[:key_dir] || KEY_DIR
85
+ @env = options[:env] || {}
86
+
87
+ @config_file_path = File.join(@path, @conf_dir, @config_file)
88
+ @conf_dir_path = File.join(@path, @conf_dir)
89
+ @key_dir_path = File.join(@path, @key_dir)
90
+
91
+ Grit::Git.git_timeout = options[:timeout] || TIMEOUT
24
92
  Grit.debug = options[:debug] || DEBUG
93
+ @gl_admin = Grit::Repo.new(path)
94
+
95
+ reload!
25
96
  end
26
97
 
27
- # This method will bootstrap a gitolite-admin repo
28
- # at the given path. A typical gitolite-admin
29
- # repo will have the following tree:
30
- #
31
- # gitolite-admin
32
- # conf
33
- # gitolite.conf
34
- # keydir
35
- def self.bootstrap(path, options = {})
36
- if self.is_gitolite_admin_repo?(path)
37
- if options[:overwrite]
38
- FileUtils.rm_rf(File.join(path, '*'))
39
- else
40
- return self.new(path)
41
- end
42
- end
43
98
 
44
- FileUtils.mkdir_p([File.join(path,"conf"), File.join(path,"keydir")])
99
+ def config
100
+ @config ||= load_config
101
+ end
45
102
 
46
- options[:perm] ||= "RW+"
47
- options[:refex] ||= ""
48
- options[:user] ||= "git"
49
103
 
50
- c = Config.init
51
- r = Config::Repo.new(options[:repo] || "gitolite-admin")
52
- r.add_permission(options[:perm], options[:refex], options[:user])
53
- c.add_repo(r)
54
- config = c.to_file(File.join(path, "conf"))
104
+ def config=(config)
105
+ @config = config
106
+ end
55
107
 
56
- repo = Grit::Repo.init(path)
57
- Dir.chdir(path) do
58
- repo.add(config)
59
- repo.commit_index(options[:message] || "Config bootstrapped by the gitolite gem")
60
- end
61
108
 
62
- self.new(path)
109
+ def ssh_keys
110
+ @ssh_keys ||= load_keys
111
+ end
112
+
113
+
114
+ def add_key(key)
115
+ raise "Key must be of type Gitolite::SSHKey!" unless key.instance_of? Gitolite::SSHKey
116
+ ssh_keys[key.owner] << key
117
+ end
118
+
119
+
120
+ def rm_key(key)
121
+ raise "Key must be of type Gitolite::SSHKey!" unless key.instance_of? Gitolite::SSHKey
122
+ ssh_keys[key.owner].delete key
123
+ end
124
+
125
+
126
+ # This method will destroy all local tracked changes, resetting the local gitolite
127
+ # git repo to HEAD and reloading the entire repository
128
+ # Note that this will also delete all untracked files
129
+ def reset!
130
+ @gl_admin.git.native(:reset, {:env => @env, :chdir => @gl_admin.working_dir, :hard => true}, 'HEAD')
131
+ @gl_admin.git.native(:clean, {:env => @env, :chdir => @gl_admin.working_dir, :d => true, :q => true, :f => true})
132
+ reload!
133
+ end
134
+
135
+
136
+ # This method will destroy the in-memory data structures and reload everything
137
+ # from the file system
138
+ def reload!
139
+ @ssh_keys = load_keys
140
+ @config = load_config
63
141
  end
64
142
 
65
- #Writes all changed aspects out to the file system
66
- #will also stage all changes
67
- def save(commit_message = DEFAULT_COMMIT_MSG)
68
- confdir = File.join(@gl_admin.working_dir, @confdir)
69
- keydir = File.join(@gl_admin.working_dir, @keydir)
143
+
144
+ # Writes all changed aspects out to the file system
145
+ # will also stage all changes then commit
146
+ def save(commit_message = DEFAULT_COMMIT_MSG, options = {})
70
147
 
71
148
  #Process config file (if loaded, i.e. may be modified)
72
149
  if @config
73
- new_conf = @config.to_file(confdir).gsub(@gl_admin.working_dir + '/', '')
74
- @gl_admin.git.native(:add, {:chdir => @gl_admin.working_dir}, new_conf)
150
+ new_conf = @config.to_file(@conf_dir_path)
151
+ @gl_admin.git.native(:add, {:env => @env, :chdir => @gl_admin.working_dir}, new_conf)
75
152
  end
76
153
 
77
154
  #Process ssh keys (if loaded, i.e. may be modified)
78
155
  if @ssh_keys
79
- files = list_keys(keydir).map{|f| File.basename f}
80
- keys = @ssh_keys.values.map{|f| f.map {|t| t.filename}}.flatten
156
+ files = list_keys.map{|f| File.basename f}
157
+ keys = @ssh_keys.values.map{|f| f.map {|t| t.filename}}.flatten
81
158
 
82
- to_remove = (files - keys).map { |f| File.join(@keydir, f) }
159
+ to_remove = (files - keys).map { |f| File.join(@key_dir, f) }
83
160
  to_remove.each do |key|
84
- @gl_admin.git.native(:rm, {:chdir => @gl_admin.working_dir}, key)
161
+ @gl_admin.git.native(:rm, {:env => @env, :chdir => @gl_admin.working_dir}, key)
85
162
  end
86
163
 
87
164
  @ssh_keys.each_value do |key|
88
- #Write only keys from sets that has been modified
165
+ # Write only keys from sets that has been modified
89
166
  next if key.respond_to?(:dirty?) && !key.dirty?
90
167
  key.each do |k|
91
- new_key = k.to_file(keydir).gsub(@gl_admin.working_dir + '/', '')
92
- @gl_admin.git.native(:add, {:chdir => @gl_admin.working_dir}, new_key)
168
+ new_key = k.to_file(@key_dir_path)
169
+ @gl_admin.git.native(:add, {:env => @env, :chdir => @gl_admin.working_dir}, new_key)
93
170
  end
94
171
  end
95
172
  end
96
173
 
97
- @gl_admin.git.native(:commit, {:chdir => @gl_admin.working_dir}, '-a', '-m', commit_message)
98
- end
174
+ args = []
99
175
 
100
- # This method will destroy all local tracked changes, resetting the local gitolite
101
- # git repo to HEAD and reloading the entire repository
102
- # Note that this will also delete all untracked files
103
- def reset!
104
- Dir.chdir(@gl_admin.working_dir) do
105
- @gl_admin.git.reset({:hard => true}, 'HEAD')
106
- @gl_admin.git.clean({:d => true, :q => true, :f => true})
176
+ if options.has_key?(:author) && !options[:author].empty?
177
+ args << "--author='#{options[:author]}'"
107
178
  end
108
- reload!
109
- end
110
179
 
111
- # This method will destroy the in-memory data structures and reload everything
112
- # from the file system
113
- def reload!
114
- @ssh_keys = load_keys
115
- @config = load_config
180
+ @gl_admin.git.native(:commit, {:env => @env, :chdir => @gl_admin.working_dir}, '-a', '-m', commit_message, args.join(' '))
116
181
  end
117
182
 
183
+
118
184
  # Push back to origin
119
185
  def apply
120
- @gl_admin.git.native(:push, {:chdir => @gl_admin.working_dir}, "origin", "master")
186
+ @gl_admin.git.native(:push, {:env => @env, :chdir => @gl_admin.working_dir}, "origin", "master")
121
187
  end
122
188
 
189
+
123
190
  # Commits all staged changes and pushes back to origin
124
191
  def save_and_apply(commit_message = DEFAULT_COMMIT_MSG)
125
- self.save(commit_message)
126
- self.apply
192
+ save(commit_message)
193
+ apply
127
194
  end
128
195
 
196
+
129
197
  # Updates the repo with changes from remote master
130
198
  def update(options = {})
131
199
  options = {:reset => true, :rebase => false}.merge(options)
132
200
 
133
201
  reset! if options[:reset]
134
202
 
135
- @gl_admin.git.native(:pull, {:chdir => @gl_admin.working_dir, :rebase => options[:rebase]}, "origin", "master")
203
+ @gl_admin.git.native(:pull, {:env => @env, :chdir => @gl_admin.working_dir, :rebase => options[:rebase]}, "origin", "master")
136
204
 
137
205
  reload!
138
206
  end
139
207
 
140
- def add_key(key)
141
- raise "Key must be of type Gitolite::SSHKey!" unless key.instance_of? Gitolite::SSHKey
142
- ssh_keys[key.owner] << key
143
- end
144
208
 
145
- def rm_key(key)
146
- raise "Key must be of type Gitolite::SSHKey!" unless key.instance_of? Gitolite::SSHKey
147
- ssh_keys[key.owner].delete key
148
- end
209
+ private
149
210
 
150
- #Checks to see if the given path is a gitolite-admin repository
151
- #A valid repository contains a conf folder, keydir folder,
152
- #and a configuration file within the conf folder
153
- def self.is_gitolite_admin_repo?(dir)
154
- # First check if it is a git repository
155
- begin
156
- Grit::Repo.new(dir)
157
- rescue Grit::InvalidGitRepositoryError
158
- return false
159
- end
160
211
 
161
- # If we got here it is a valid git repo,
162
- # now check directory structure
163
- File.exists?(File.join(dir, 'conf')) &&
164
- File.exists?(File.join(dir, 'keydir')) &&
165
- !Dir.glob(File.join(dir, 'conf', '*.conf')).empty?
212
+ def load_config
213
+ Config.new(@config_file_path)
166
214
  end
167
215
 
168
- def ssh_keys
169
- @ssh_keys ||= load_keys
170
- end
171
216
 
172
- def config
173
- @config ||= load_config
174
- end
175
-
176
- def config=(config)
177
- @config = config
217
+ def list_keys
218
+ Dir.glob(@key_dir_path + '/**/*.pub')
178
219
  end
179
220
 
180
- private
181
- #Loads all .pub files in the gitolite-admin
182
- #keydir directory
183
- def load_keys(path = nil)
184
- path ||= File.join(@path, @keydir)
185
- keys = Hash.new {|k,v| k[v] = DirtyProxy.new([])}
186
221
 
187
- list_keys(path).each do |key|
188
- new_key = SSHKey.from_file(key)
189
- owner = new_key.owner
222
+ # Loads all .pub files in the gitolite-admin
223
+ # keydir directory
224
+ def load_keys
225
+ keys = Hash.new {|k,v| k[v] = DirtyProxy.new([])}
190
226
 
191
- keys[owner] << new_key
192
- end
193
- #Mark key sets as unmodified (for dirty checking)
194
- keys.values.each{|set| set.clean_up!}
227
+ list_keys.each do |key|
228
+ new_key = SSHKey.from_file(key)
229
+ owner = new_key.owner
195
230
 
196
- keys
231
+ keys[owner] << new_key
197
232
  end
198
233
 
199
- def load_config(path = nil)
200
- path ||= File.join(@path, @confdir, @conf)
201
- Config.new(path)
202
- end
234
+ # Mark key sets as unmodified (for dirty checking)
235
+ keys.values.each{|set| set.clean_up!}
236
+
237
+ keys
238
+ end
203
239
 
204
- def list_keys(path)
205
- keys = Dir.glob(path + '/**/*.pub')
206
- keys
207
- end
208
240
  end
209
241
  end
@@ -1,3 +1,3 @@
1
1
  module Gitolite
2
- VERSION = "1.1.10"
2
+ VERSION = "1.1.11"
3
3
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbox-gitolite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-31 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.9.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: forgery
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.5.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov-rcov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ci_reporter
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: 10.0.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 10.0.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: gitlab-grit
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: 2.6.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: 2.6.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: gratr19
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ~>
130
130
  - !ruby/object:Gem::Version
131
131
  version: 0.4.4.1
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.4.4.1
139
139
  description: This gem is designed to provide a Ruby interface to the gitolite git
@@ -145,12 +145,12 @@ executables: []
145
145
  extensions: []
146
146
  extra_rdoc_files: []
147
147
  files:
148
- - ".gemtest"
149
- - ".gitignore"
150
- - ".travis.yml"
148
+ - .gemtest
149
+ - .gitignore
150
+ - .travis.yml
151
151
  - Gemfile
152
- - LICENSE
153
- - README.markdown
152
+ - LICENSE.txt
153
+ - README.md
154
154
  - Rakefile
155
155
  - gitolite.gemspec
156
156
  - lib/gitolite.rb
@@ -193,12 +193,12 @@ require_paths:
193
193
  - lib
194
194
  required_ruby_version: !ruby/object:Gem::Requirement
195
195
  requirements:
196
- - - ">="
196
+ - - '>='
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
- - - ">="
201
+ - - '>='
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []