Commit c02ec5b6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'shell_style' into 'master'

Shell Style
parents 79bceae6 73c8ea9c
...@@ -10,18 +10,18 @@ config = GitlabConfig.new ...@@ -10,18 +10,18 @@ config = GitlabConfig.new
key_dir = File.dirname("#{config.auth_file}") key_dir = File.dirname("#{config.auth_file}")
commands = [ commands = [
"mkdir -p #{config.repos_path}", %W(mkdir -p #{config.repos_path}),
"mkdir -p #{key_dir}", %W(mkdir -p #{key_dir}),
"chmod 700 #{key_dir}", %W(chmod 700 #{key_dir}),
"touch #{config.auth_file}", %W(touch #{config.auth_file}),
"chmod 600 #{config.auth_file}", %W(chmod 600 #{config.auth_file}),
"chmod -R ug+rwX,o-rwx #{config.repos_path}", %W(chmod -R ug+rwX,o-rwx #{config.repos_path}),
"find #{config.repos_path} -type d -print0 | xargs -0 chmod g+s" %W(find #{config.repos_path} -type d -exec chmod g+s {} ;)
] ]
commands.each do |cmd| commands.each do |cmd|
print "#{cmd}: " print "#{cmd.join(' ')}: "
if system(cmd) if system(*cmd)
puts 'OK' puts 'OK'
else else
puts 'Failed' puts 'Failed'
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
refname = ARGV[0] refname = ARGV[0]
key_id = ENV['GL_ID'] key_id = ENV['GL_ID']
repo_path = `pwd` repo_path = Dir.pwd
require_relative '../lib/gitlab_update' require_relative '../lib/gitlab_update'
......
...@@ -31,8 +31,8 @@ describe GitlabProjects do ...@@ -31,8 +31,8 @@ describe GitlabProjects do
it "should create a branch" do it "should create a branch" do
gl_projects_create.exec gl_projects_create.exec
gl_projects.exec gl_projects.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))
master_ref = `cd #{tmp_repo_path} && git rev-parse master`.strip master_ref = capture_in_tmp_repo(%W(git rev-parse master))
branch_ref.should == master_ref branch_ref.should == master_ref
end end
end end
...@@ -49,9 +49,9 @@ describe GitlabProjects do ...@@ -49,9 +49,9 @@ describe GitlabProjects do
it "should remove a branch" do it "should remove a branch" do
gl_projects_create.exec gl_projects_create.exec
gl_projects_create_branch.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 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 branch_del.should_not == branch_ref
end end
end end
...@@ -65,8 +65,8 @@ describe GitlabProjects do ...@@ -65,8 +65,8 @@ describe GitlabProjects do
it "should create a tag" do it "should create a tag" do
gl_projects_create.exec gl_projects_create.exec
gl_projects.exec gl_projects.exec
tag_ref = `cd #{tmp_repo_path} && git rev-parse test_tag`.strip tag_ref = capture_in_tmp_repo(%W(git rev-parse test_tag))
master_ref = `cd #{tmp_repo_path} && git rev-parse master`.strip master_ref = capture_in_tmp_repo(%W(git rev-parse master))
tag_ref.should == master_ref tag_ref.should == master_ref
end end
end end
...@@ -83,9 +83,9 @@ describe GitlabProjects do ...@@ -83,9 +83,9 @@ describe GitlabProjects do
it "should remove a branch" do it "should remove a branch" do
gl_projects_create.exec gl_projects_create.exec
gl_projects_create_tag.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 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 branch_del.should_not == branch_ref
end end
end end
...@@ -179,8 +179,8 @@ describe GitlabProjects do ...@@ -179,8 +179,8 @@ describe GitlabProjects do
before do before do
FileUtils.mkdir_p(tmp_repo_path) FileUtils.mkdir_p(tmp_repo_path)
system("git init --bare #{tmp_repo_path}") system(*%W(git init --bare #{tmp_repo_path}))
system("touch #{tmp_repo_path}/refs/heads/stable") FileUtils.touch(File.join(tmp_repo_path, "refs/heads/stable"))
File.read(File.join(tmp_repo_path, 'HEAD')).strip.should == 'ref: refs/heads/master' File.read(File.join(tmp_repo_path, 'HEAD')).strip.should == 'ref: refs/heads/master'
end end
...@@ -300,4 +300,8 @@ describe GitlabProjects do ...@@ -300,4 +300,8 @@ describe GitlabProjects do
def repo_name def repo_name
'gitlab-ci.git' 'gitlab-ci.git'
end end
def capture_in_tmp_repo(cmd)
IO.popen(cmd, chdir: tmp_repo_path).read.strip
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment