diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-20 10:14:20 +0000 |
---|---|---|
committer | Alejandro RodrÃguez <alejorro70@gmail.com> | 2017-01-24 00:08:24 -0300 |
commit | c69ed361fe8bef95a84f8ae8223329d4bd746a14 (patch) | |
tree | dfc62c1c6f43894ba92a9a20883664d4377c6371 | |
parent | d19a4135884b14a0b576c1160ccd159a9bed9bd7 (diff) | |
download | gitlab-ce-c69ed361fe8bef95a84f8ae8223329d4bd746a14.tar.gz |
Merge branch '25848-fix-git-rev-list-env-parsing' into 'master'
Reject blank environment variables in Gitlab::Git::RevList
Closes #25848
See merge request !8189
-rw-r--r-- | lib/gitlab/git/rev_list.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/git/rev_list_spec.rb | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/gitlab/git/rev_list.rb b/lib/gitlab/git/rev_list.rb index 25e9d619697..79dd0cf7df2 100644 --- a/lib/gitlab/git/rev_list.rb +++ b/lib/gitlab/git/rev_list.rb @@ -22,7 +22,7 @@ module Gitlab def valid? environment_variables.all? do |(name, value)| - value.start_with?(project.repository.path_to_repo) + value.to_s.start_with?(project.repository.path_to_repo) end end @@ -35,7 +35,7 @@ module Gitlab end def environment_variables - @environment_variables ||= env.slice(*ALLOWED_VARIABLES) + @environment_variables ||= env.slice(*ALLOWED_VARIABLES).compact end end end diff --git a/spec/lib/gitlab/git/rev_list_spec.rb b/spec/lib/gitlab/git/rev_list_spec.rb index 444639acbaa..1f9c987be0b 100644 --- a/spec/lib/gitlab/git/rev_list_spec.rb +++ b/spec/lib/gitlab/git/rev_list_spec.rb @@ -26,6 +26,13 @@ describe Gitlab::Git::RevList, lib: true do expect(rev_list).not_to be_valid end + + it "ignores nil values" do + env = { var => nil } + rev_list = described_class.new('oldrev', 'newrev', project: project, env: env) + + expect(rev_list).to be_valid + end end end end |