end
def self.find_commit_range(current_user, repository, minimum, maximum, exclude)
- if (minimum and !git_check_ref_format(minimum)) or !git_check_ref_format(maximum)
- logger.warn "find_commit_range called with invalid minimum or maximum: '#{minimum}', '#{maximum}'"
+ if minimum and minimum.empty?
+ minimum = nil
+ end
+
+ if minimum and !git_check_ref_format(minimum)
+ logger.warn "find_commit_range called with invalid minimum revision: '#{minimum}'"
return nil
end
- if minimum and minimum.empty?
- minimum = nil
+ if maximum and !git_check_ref_format(maximum)
+ logger.warn "find_commit_range called with invalid maximum revision: '#{maximum}'"
+ return nil
end
if !maximum
# Get the commit hash for the upper bound
max_hash = nil
- IO.foreach("|git rev-list --max-count=1 #{maximum.shellescape}") do |line|
+ IO.foreach("|git rev-list --max-count=1 #{maximum.shellescape} --") do |line|
max_hash = line.strip
end
resolved_exclude = []
exclude.each do |e|
if git_check_ref_format(e)
- IO.foreach("|git rev-list --max-count=1 #{e.shellescape}") do |line|
+ IO.foreach("|git rev-list --max-count=1 #{e.shellescape} --") do |line|
resolved_exclude.push(line.strip)
end
else
if minimum
# Get the commit hash for the lower bound
min_hash = nil
- IO.foreach("|git rev-list --max-count=1 #{minimum.shellescape}") do |line|
+ IO.foreach("|git rev-list --max-count=1 #{minimum.shellescape} --") do |line|
min_hash = line.strip
end
next if !min_hash or !git_check_ref_format(min_hash)
# Now find all commits between them
- IO.foreach("|git rev-list #{min_hash.shellescape}..#{max_hash.shellescape}") do |line|
+ IO.foreach("|git rev-list #{min_hash.shellescape}..#{max_hash.shellescape} --") do |line|
hash = line.strip
commits.push(hash) if !resolved_exclude or !resolved_exclude.include? hash
end
else
commits.push(max_hash) if !resolved_exclude or !resolved_exclude.include? max_hash
end
+ else
+ logger.warn "Repository #{r.name} exists in table but not found on disk"
end
end
next if repo.match /^\./
git_dir = File.join(@gitdirbase,
repo.match(/\.git$/) ? repo : File.join(repo, '.git'))
+ next if git_dir == Rails.configuration.git_internal_dir
repo_name = repo.sub(/\.git$/, '')
@repositories[repo_name] = {git_dir: git_dir}
end