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
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'
......
......@@ -6,7 +6,7 @@
refname = ARGV[0]
key_id = ENV['GL_ID']
repo_path = `pwd`
repo_path = Dir.pwd
require_relative '../lib/gitlab_update'
......
......@@ -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
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