Mercurial > hg > soundsoftware-site
comparison lib/redmine/scm/adapters/git_adapter.rb @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 94944d00e43c |
children | 0579821a129a |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 119:8661b858af72 |
---|---|
87 def lastrev(path,rev) | 87 def lastrev(path,rev) |
88 return nil if path.nil? | 88 return nil if path.nil? |
89 cmd = "#{GIT_BIN} --git-dir #{target('')} log --no-color --date=iso --pretty=fuller --no-merges -n 1 " | 89 cmd = "#{GIT_BIN} --git-dir #{target('')} log --no-color --date=iso --pretty=fuller --no-merges -n 1 " |
90 cmd << " #{shell_quote rev} " if rev | 90 cmd << " #{shell_quote rev} " if rev |
91 cmd << "-- #{shell_quote path} " unless path.empty? | 91 cmd << "-- #{shell_quote path} " unless path.empty? |
92 shellout(cmd) do |io| | 92 lines = [] |
93 begin | 93 shellout(cmd) { |io| lines = io.readlines } |
94 id = io.gets.split[1] | 94 return nil if $? && $?.exitstatus != 0 |
95 author = io.gets.match('Author:\s+(.*)$')[1] | 95 begin |
96 2.times { io.gets } | 96 id = lines[0].split[1] |
97 time = Time.parse(io.gets.match('CommitDate:\s+(.*)$')[1]).localtime | 97 author = lines[1].match('Author:\s+(.*)$')[1] |
98 time = Time.parse(lines[4].match('CommitDate:\s+(.*)$')[1]).localtime | |
98 | 99 |
99 Revision.new({ | 100 Revision.new({ |
100 :identifier => id, | 101 :identifier => id, |
101 :scmid => id, | 102 :scmid => id, |
102 :author => author, | 103 :author => author, |
103 :time => time, | 104 :time => time, |
104 :message => nil, | 105 :message => nil, |
105 :paths => nil | 106 :paths => nil |
106 }) | 107 }) |
107 rescue NoMethodError => e | 108 rescue NoMethodError => e |
108 logger.error("The revision '#{path}' has a wrong format") | 109 logger.error("The revision '#{path}' has a wrong format") |
109 return nil | 110 return nil |
110 end | |
111 end | 111 end |
112 end | 112 end |
113 | 113 |
114 def revisions(path, identifier_from, identifier_to, options={}) | 114 def revisions(path, identifier_from, identifier_to, options={}) |
115 revisions = Revisions.new | 115 revisions = Revisions.new |
116 | 116 |
117 cmd = "#{GIT_BIN} --git-dir #{target('')} log --no-color --raw --date=iso --pretty=fuller " | 117 cmd = "#{GIT_BIN} --git-dir #{target('')} log --no-color --raw --date=iso --pretty=fuller " |
118 cmd << " --reverse " if options[:reverse] | 118 cmd << " --reverse " if options[:reverse] |
119 cmd << " --all " if options[:all] | 119 cmd << " --all " if options[:all] |
120 cmd << " -n #{options[:limit]} " if options[:limit] | 120 cmd << " -n #{options[:limit].to_i} " if options[:limit] |
121 cmd << "#{shell_quote(identifier_from + '..')}" if identifier_from | 121 cmd << "#{shell_quote(identifier_from + '..')}" if identifier_from |
122 cmd << "#{shell_quote identifier_to}" if identifier_to | 122 cmd << "#{shell_quote identifier_to}" if identifier_to |
123 cmd << " --since=#{shell_quote(options[:since].strftime("%Y-%m-%d %H:%M:%S"))}" if options[:since] | 123 cmd << " --since=#{shell_quote(options[:since].strftime("%Y-%m-%d %H:%M:%S"))}" if options[:since] |
124 cmd << " -- #{shell_quote path}" if path && !path.empty? | 124 cmd << " -- #{shell_quote path}" if path && !path.empty? |
125 | 125 |
262 cat = io.read | 262 cat = io.read |
263 end | 263 end |
264 return nil if $? && $?.exitstatus != 0 | 264 return nil if $? && $?.exitstatus != 0 |
265 cat | 265 cat |
266 end | 266 end |
267 | |
268 class Revision < Redmine::Scm::Adapters::Revision | |
269 # Returns the readable identifier | |
270 def format_identifier | |
271 identifier[0,8] | |
272 end | |
273 end | |
267 end | 274 end |
268 end | 275 end |
269 end | 276 end |
270 end | 277 end |