blob: d8c78d806ea8bd211cbe83f7549aeb81a73c6e0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# Call out to the `git rev-list` command
module Gitlab
module Git
class RevList
include ActiveModel::Validations
validates :env, git_environment_variables: true
attr_reader :project, :env
def initialize(oldrev, newrev, project:, env: nil)
@project = project
@env = env.presence || {}
@args = [Gitlab.config.git.bin_path,
"--git-dir=#{project.repository.path_to_repo}",
"rev-list",
"--max-count=1",
oldrev,
"^#{newrev}"]
end
def execute
if self.valid?
Gitlab::Popen.popen(@args, nil, @env.slice(*allowed_environment_variables))
else
Gitlab::Popen.popen(@args)
end
end
private
def allowed_environment_variables
%w(GIT_ALTERNATE_OBJECT_DIRECTORIES GIT_OBJECT_DIRECTORY)
end
end
end
end
|