diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-11 13:21:22 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-11 13:21:22 +0000 |
commit | c02ec5b68778a46024b1dd4e28a1e482359d9a62 (patch) | |
tree | f256ee7fe52b2c7729ad08f29af0355baf17715d | |
parent | 79bceae69cb5750d6567b223597999bfa91cb3b9 (diff) | |
parent | 73c8ea9c0f7fe3d4ab4b829dc348c17e58490ee4 (diff) | |
download | gitlab-shell-c02ec5b68778a46024b1dd4e28a1e482359d9a62.tar.gz |
Merge branch 'shell_style' into 'master'
Shell Style
-rwxr-xr-x | bin/install | 18 | ||||
-rwxr-xr-x | hooks/update | 2 | ||||
-rw-r--r-- | spec/gitlab_projects_spec.rb | 24 |
3 files changed, 24 insertions, 20 deletions
diff --git a/bin/install b/bin/install index c55d0da..64ae726 100755 --- a/bin/install +++ b/bin/install @@ -10,18 +10,18 @@ config = GitlabConfig.new key_dir = File.dirname("#{config.auth_file}") commands = [ - "mkdir -p #{config.repos_path}", - "mkdir -p #{key_dir}", - "chmod 700 #{key_dir}", - "touch #{config.auth_file}", - "chmod 600 #{config.auth_file}", - "chmod -R ug+rwX,o-rwx #{config.repos_path}", - "find #{config.repos_path} -type d -print0 | xargs -0 chmod g+s" + %W(mkdir -p #{config.repos_path}), + %W(mkdir -p #{key_dir}), + %W(chmod 700 #{key_dir}), + %W(touch #{config.auth_file}), + %W(chmod 600 #{config.auth_file}), + %W(chmod -R ug+rwX,o-rwx #{config.repos_path}), + %W(find #{config.repos_path} -type d -exec chmod g+s {} ;) ] commands.each do |cmd| - print "#{cmd}: " - if system(cmd) + print "#{cmd.join(' ')}: " + if system(*cmd) puts 'OK' else puts 'Failed' diff --git a/hooks/update b/hooks/update index 549afeb..6f762e8 100755 --- a/hooks/update +++ b/hooks/update @@ -6,7 +6,7 @@ refname = ARGV[0] key_id = ENV['GL_ID'] -repo_path = `pwd` +repo_path = Dir.pwd require_relative '../lib/gitlab_update' diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index 4341ca5..dbdbfd9 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -31,8 +31,8 @@ describe GitlabProjects do it "should create a branch" do gl_projects_create.exec gl_projects.exec - branch_ref = `cd #{tmp_repo_path} && git rev-parse test_branch`.strip - master_ref = `cd #{tmp_repo_path} && git rev-parse master`.strip + branch_ref = capture_in_tmp_repo(%W(git rev-parse test_branch)) + master_ref = capture_in_tmp_repo(%W(git rev-parse master)) branch_ref.should == master_ref end end @@ -49,9 +49,9 @@ describe GitlabProjects do it "should remove a branch" do gl_projects_create.exec gl_projects_create_branch.exec - branch_ref = `cd #{tmp_repo_path} && git rev-parse test_branch`.strip + branch_ref = capture_in_tmp_repo(%W(git rev-parse test_branch)) gl_projects.exec - branch_del = `cd #{tmp_repo_path} && git rev-parse test_branch`.strip + branch_del = capture_in_tmp_repo(%W(git rev-parse test_branch)) branch_del.should_not == branch_ref end end @@ -65,8 +65,8 @@ describe GitlabProjects do it "should create a tag" do gl_projects_create.exec gl_projects.exec - tag_ref = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip - master_ref = `cd #{tmp_repo_path} && git rev-parse master`.strip + tag_ref = capture_in_tmp_repo(%W(git rev-parse test_tag)) + master_ref = capture_in_tmp_repo(%W(git rev-parse master)) tag_ref.should == master_ref end end @@ -83,9 +83,9 @@ describe GitlabProjects do it "should remove a branch" do gl_projects_create.exec gl_projects_create_tag.exec - branch_ref = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip + branch_ref = capture_in_tmp_repo(%W(git rev-parse test_tag)) gl_projects.exec - branch_del = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip + branch_del = capture_in_tmp_repo(%W(git rev-parse test_tag)) branch_del.should_not == branch_ref end end @@ -179,8 +179,8 @@ describe GitlabProjects do before do FileUtils.mkdir_p(tmp_repo_path) - system("git init --bare #{tmp_repo_path}") - system("touch #{tmp_repo_path}/refs/heads/stable") + system(*%W(git init --bare #{tmp_repo_path})) + FileUtils.touch(File.join(tmp_repo_path, "refs/heads/stable")) File.read(File.join(tmp_repo_path, 'HEAD')).strip.should == 'ref: refs/heads/master' end @@ -300,4 +300,8 @@ describe GitlabProjects do def repo_name 'gitlab-ci.git' end + + def capture_in_tmp_repo(cmd) + IO.popen(cmd, chdir: tmp_repo_path).read.strip + end end |