Feature #5386 » tags.patch
| app/models/repository/git.rb | ||
|---|---|---|
|
# -*- coding: utf-8 -*-
|
||
|
# Redmine - project management software
|
||
|
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
||
|
# Copyright (C) 2007 Patrick Aljord patcito@ŋmail.com
|
||
| ... | ... | |
|
# Returns the readable identifier for the given git changeset
|
||
|
def self.format_changeset_identifier(changeset)
|
||
|
changeset.revision[0, 8]
|
||
|
str = changeset.revision[0, 8]
|
||
|
h = changeset.repository.extra_info
|
||
|
unless h.nil? || h['refs'].nil?
|
||
|
ref = h['refs'][changeset.revision.to_s]
|
||
|
str += ' [' + ref.join(', ') + ']' if ref.respond_to?('join')
|
||
|
end
|
||
|
str
|
||
|
end
|
||
|
def branches
|
||
| ... | ... | |
|
scm.tags
|
||
|
end
|
||
|
def refs
|
||
|
scm.refs
|
||
|
end
|
||
|
def default_branch
|
||
|
scm.default_branch
|
||
|
rescue Exception => e
|
||
| ... | ... | |
|
def fetch_changesets
|
||
|
scm_brs = branches
|
||
|
return if scm_brs.nil? || scm_brs.empty?
|
||
|
merge_extra_info('refs' => refs)
|
||
|
self.save
|
||
|
h1 = extra_info || {}
|
||
|
h = h1.dup
|
||
| lib/redmine/scm/adapters/git_adapter.rb | ||
|---|---|---|
|
# -*- coding: utf-8 -*-
|
||
|
# Redmine - project management software
|
||
|
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
||
|
#
|
||
| ... | ... | |
|
def branches
|
||
|
return @branches if @branches
|
||
|
@branches = []
|
||
|
cmd_args = %w|branch --no-color --verbose --no-abbrev|
|
||
|
git_cmd(cmd_args) do |io|
|
||
|
io.each_line do |line|
|
||
|
branch_rev = line.match('\s*(\*?)\s*(.*?)\s*([0-9a-f]{40}).*$')
|
||
|
bran = GitBranch.new(branch_rev[2])
|
||
|
bran.revision = branch_rev[3]
|
||
|
bran.scmid = branch_rev[3]
|
||
|
bran.is_default = ( branch_rev[1] == '*' )
|
||
|
@branches << bran
|
||
|
end
|
||
|
end
|
||
|
@branches.sort!
|
||
|
rescue ScmCommandAborted
|
||
|
nil
|
||
|
refs
|
||
|
@branches
|
||
|
end
|
||
|
def tags
|
||
|
return @tags if @tags
|
||
|
cmd_args = %w|tag|
|
||
|
refs
|
||
|
@tags
|
||
|
end
|
||
|
def refs
|
||
|
return @refs if @refs
|
||
|
cmd_args = %w|show-ref --head --tags --heads --dereference|
|
||
|
git_cmd(cmd_args) do |io|
|
||
|
@tags = io.readlines.sort!.map{|t| t.strip}
|
||
|
head = nil
|
||
|
@refs = {}
|
||
|
@branches = []
|
||
|
@tags = []
|
||
|
io.each do |line|
|
||
|
rev,ref = line.split
|
||
|
if m = ref.match(%r|^HEAD$|)
|
||
|
head = rev
|
||
|
elsif m = ref.match(%r|^refs/heads/(.*)|)
|
||
|
@refs[rev] ||= []
|
||
|
@refs[rev] << m[1]
|
||
|
b = GitBranch.new(m[1])
|
||
|
b.revision = rev
|
||
|
b.scmid = rev
|
||
|
b.is_default = false
|
||
|
@branches << b
|
||
|
elsif m = ref.match(%r|^refs/tags/(.*)\^{}$|)
|
||
|
@refs[rev] ||= []
|
||
|
@refs[rev] << "tag: #{m[1]}"
|
||
|
@tags << m[1]
|
||
|
end
|
||
|
end
|
||
|
@branches.sort!.map!{ |b|
|
||
|
b.is_default = true if b.revision == head
|
||
|
b
|
||
|
}
|
||
|
@tags.sort!
|
||
|
end
|
||
|
@refs
|
||
|
rescue ScmCommandAborted
|
||
|
@branches = nil
|
||
|
@tags = nil
|
||
|
nil
|
||
|
end
|
||