136 |
134 |
entries.sort_by_name
|
137 |
135 |
end
|
138 |
136 |
|
|
137 |
def rev_revisions(path, identifier_from, identifier_to, options={})
|
|
138 |
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw --reverse"
|
|
139 |
cmd << " -n #{options[:limit].to_i} " if (!options.nil?) && options[:limit]
|
|
140 |
cmd << " #{shell_quote(identifier_from + '..')} " if identifier_from
|
|
141 |
cmd << " #{shell_quote identifier_to} " if identifier_to
|
|
142 |
#cmd << " HEAD " if !identifier_to
|
|
143 |
shellout(cmd) do |io|
|
|
144 |
files=[]
|
|
145 |
changeset = {}
|
|
146 |
parsing_descr = 0 #0: not parsing desc or files, 1: parsing desc, 2: parsing files
|
|
147 |
revno = 1
|
|
148 |
|
|
149 |
io.each_line do |line|
|
|
150 |
if line =~ /^commit ([0-9a-f]{40})$/
|
|
151 |
key = "commit"
|
|
152 |
value = $1
|
|
153 |
if (parsing_descr == 1 || parsing_descr == 2)
|
|
154 |
parsing_descr = 0
|
|
155 |
yield Revision.new({:identifier => changeset[:commit],
|
|
156 |
:scmid => changeset[:commit],
|
|
157 |
:author => changeset[:author],
|
|
158 |
:time => Time.parse(changeset[:date]),
|
|
159 |
:message => changeset[:description],
|
|
160 |
:paths => files
|
|
161 |
})
|
|
162 |
changeset = {}
|
|
163 |
files = []
|
|
164 |
revno = revno + 1
|
|
165 |
end
|
|
166 |
changeset[:commit] = $1
|
|
167 |
elsif (parsing_descr == 0) && line =~ /^(\w+):\s*(.*)$/
|
|
168 |
key = $1
|
|
169 |
value = $2
|
|
170 |
if key == "Author"
|
|
171 |
changeset[:author] = value
|
|
172 |
elsif key == "Date"
|
|
173 |
changeset[:date] = value
|
|
174 |
end
|
|
175 |
elsif (parsing_descr == 0) && line.chomp.to_s == ""
|
|
176 |
parsing_descr = 1
|
|
177 |
changeset[:description] = ""
|
|
178 |
elsif (parsing_descr == 1 || parsing_descr == 2) && line =~ /^:\d+\s+\d+\s+[0-9a-f.]+\s+[0-9a-f.]+\s+(\w)\s+(.+)$/
|
|
179 |
parsing_descr = 2
|
|
180 |
fileaction = $1
|
|
181 |
filepath = $2
|
|
182 |
files << {:action => fileaction, :path => filepath}
|
|
183 |
elsif (parsing_descr == 1) && line.chomp.to_s == ""
|
|
184 |
parsing_descr = 2
|
|
185 |
elsif (parsing_descr == 1)
|
|
186 |
changeset[:description] << line[4..-1]
|
|
187 |
end
|
|
188 |
end
|
|
189 |
|
|
190 |
yield Revision.new({:identifier => changeset[:commit],
|
|
191 |
:scmid => changeset[:commit],
|
|
192 |
:author => changeset[:author],
|
|
193 |
:time => Time.parse(changeset[:date]),
|
|
194 |
:message => changeset[:description],
|
|
195 |
:paths => files
|
|
196 |
}) if changeset[:commit]
|
|
197 |
|
|
198 |
end
|
|
199 |
end
|
|
200 |
|
139 |
201 |
def revisions(path, identifier_from, identifier_to, options={})
|
140 |
202 |
revisions = Revisions.new
|
141 |
203 |
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "
|