Commit ed931f3a49613793d818a820f63f11356698b222
Exists in
master
and in
4 other branches
Merge pull request #1958 from japgolly/git_commit_fix
Ensure git can commit and prevent it from failing silently
Showing
3 changed files
with
30 additions
and
4 deletions
Show diff stats
doc/install/installation.md
... | ... | @@ -180,6 +180,14 @@ and ensure you have followed all of the above steps carefully. |
180 | 180 | sudo gem install bundler |
181 | 181 | sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment |
182 | 182 | |
183 | +#### Configure git client | |
184 | + | |
185 | +Gitlab needs to be able to commit and push changes to gitolite. | |
186 | +Git requires a username and email in order to be able to do that. | |
187 | + | |
188 | + sudo -u gitlab -H git config --global user.email "gitlab@localhost" | |
189 | + sudo -u gitlab -H git config --global user.name "Gitlab" | |
190 | + | |
183 | 191 | #### Setup application |
184 | 192 | |
185 | 193 | sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production | ... | ... |
lib/gitlab/backend/gitolite_config.rb
... | ... | @@ -194,8 +194,10 @@ module Gitlab |
194 | 194 | |
195 | 195 | def push tmp_dir |
196 | 196 | Dir.chdir(File.join(tmp_dir, "gitolite")) |
197 | - system('git add -A') | |
198 | - system('git commit -am "GitLab"') | |
197 | + raise "Git add failed." unless system('git add -A') | |
198 | + system('git commit -m "GitLab"') # git commit returns 0 on success, and 1 if there is nothing to commit | |
199 | + raise "Git commit failed." unless [0,1].include? $?.exitstatus | |
200 | + | |
199 | 201 | if system('git push') |
200 | 202 | Dir.chdir(Rails.root) |
201 | 203 | else | ... | ... |
lib/tasks/gitlab/status.rake
... | ... | @@ -37,9 +37,10 @@ namespace :gitlab do |
37 | 37 | return |
38 | 38 | end |
39 | 39 | |
40 | + FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | |
40 | 41 | begin |
41 | - `git clone #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` | |
42 | - FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | |
42 | + `git clone -q #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` | |
43 | + raise unless $?.success? | |
43 | 44 | print "Can clone gitolite-admin?............" |
44 | 45 | puts "YES".green |
45 | 46 | rescue |
... | ... | @@ -48,6 +49,21 @@ namespace :gitlab do |
48 | 49 | return |
49 | 50 | end |
50 | 51 | |
52 | + begin | |
53 | + Dir.chdir("/tmp/gitolite_gitlab_test") do | |
54 | + `touch blah && git add blah && git commit -qm blah -- blah` | |
55 | + raise unless $?.success? | |
56 | + end | |
57 | + print "Can git commit?............" | |
58 | + puts "YES".green | |
59 | + rescue | |
60 | + print "Can git commit?............" | |
61 | + puts "NO".red | |
62 | + return | |
63 | + ensure | |
64 | + FileUtils.rm_rf("/tmp/gitolite_gitlab_test") | |
65 | + end | |
66 | + | |
51 | 67 | print "UMASK for .gitolite.rc is 0007? ............" |
52 | 68 | if open(File.absolute_path("#{git_base_path}/../.gitolite.rc")).grep(/UMASK([ \t]*)=([ \t>]*)0007/).any? |
53 | 69 | puts "YES".green | ... | ... |