Project

General

Profile

Patch #7829 ยป 0001-Show-branches-through-the-git-branch-command.patch

Ivan Evtuhovich, 2011-03-11 09:54

View differences:

app/models/changeset.rb
162 162
                  :from_path => change[:from_path],
163 163
                  :from_revision => change[:from_revision])
164 164
  end
165
  
165

  
166
  def branches
167
    repository.scm.get_branches(scmid)
168
  end
169

  
166 170
  private
167 171

  
168 172
  # Finds issues that can be referenced by the commit message
......
181 185
    return @short_comments, @long_comments
182 186
  end
183 187

  
184
  def branches
185
    repository.scm.get_branches(scmid)
186
  end
187

  
188 188
  def self.to_utf8(str)
189 189
    return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
190 190
    encoding = Setting.commit_logs_encoding.to_s.strip
lib/redmine/scm/adapters/git_adapter.rb
46 46

  
47 47
        def get_branches(scmid)
48 48
          result = []
49
          branches.each do |branch|
50
            cmd = "#{GIT_BIN} --git-dir #{target('')} log --pretty=oneline #{branch}"
51
            shellout(cmd) do |io|
52
              io.each_line do |line|
53
                if line.include?(scmid)
54
                  result << branch
55
                  break
56
                end
57
              end
49
          cmd = "#{GIT_BIN} --git-dir #{target('')} branch --no-color --contains #{scmid}"
50
          shellout(cmd) do |io|
51
            io.each_line do |line|
52
              line = line[1..-1] if line =~ /^\*/ # current branch marked by star
53
              result << line.strip
58 54
            end
59 55
          end
60 56

  
61
          result.uniq
57
          result.sort!
62 58
        end
63 59

  
64 60
        def tags
    (1-1/1)