git-trac 0.0.20080127 → 0.0.20080204
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/git/trac/attachment.rb +1 -1
- data/lib/git/trac/repository.rb +6 -19
- data/lib/git/trac/runner.rb +4 -10
- data/lib/git/trac/ticket.rb +7 -7
- data/test/execution_test.rb +7 -7
- metadata +2 -2
data/lib/git/trac/attachment.rb
CHANGED
@@ -116,7 +116,7 @@ module Git
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def apply(options = {})
|
119
|
-
repository.popen3("git
|
119
|
+
repository.popen3("git","apply", "-p#{p_level}", "--cached", "--whitespace=nowarn") do |inn,out,err|
|
120
120
|
inn.puts patch_with_root(options[:root])
|
121
121
|
inn.close
|
122
122
|
err.read.empty?
|
data/lib/git/trac/repository.rb
CHANGED
@@ -37,23 +37,10 @@ module Git
|
|
37
37
|
Dir.chdir(File.dirname(@git_dir),&block)
|
38
38
|
end
|
39
39
|
|
40
|
-
# Open3.popen3 in the current working tree.
|
41
|
-
# argument is converted to flags that precede the arguments.
|
42
|
-
# <tt>:foo_bar => "baz"</tt> becomes <tt>--foo-bar=baz</tt>
|
40
|
+
# Open3.popen3 in the current working tree.
|
43
41
|
def popen3(*args,&block)
|
44
42
|
args.flatten!
|
45
43
|
cmd = args.shift
|
46
|
-
if args.last.kind_of?(Hash)
|
47
|
-
args.pop.each do |k,v|
|
48
|
-
k = k.to_s.tr('-_','_-')
|
49
|
-
opt = case v
|
50
|
-
when true then "#{k}"
|
51
|
-
when false then "no-#{k}"
|
52
|
-
else "#{k}=#{v}"
|
53
|
-
end
|
54
|
-
args.unshift "--#{opt}"
|
55
|
-
end
|
56
|
-
end
|
57
44
|
in_work_tree { Open3.popen3(cmd,*args,&block) }
|
58
45
|
end
|
59
46
|
|
@@ -87,11 +74,11 @@ module Git
|
|
87
74
|
# Call git-rev-parse on a revision, returning nil if nothing is found.
|
88
75
|
def rev_parse(rev)
|
89
76
|
if rev.kind_of?(String)
|
90
|
-
exec("git
|
77
|
+
exec("git","rev-parse","--verify",rev).chomp
|
91
78
|
elsif rev.kind_of?(Array)
|
92
79
|
hash = {}
|
93
80
|
return hash if rev.empty?
|
94
|
-
exec("git
|
81
|
+
exec("git","rev-parse",*rev) do |rev|
|
95
82
|
hash[name] = rev.chomp if rev.chomp =~ /^[0-9a-f]{40}$/
|
96
83
|
end
|
97
84
|
hash
|
@@ -100,7 +87,7 @@ module Git
|
|
100
87
|
|
101
88
|
def each_ref(*args)
|
102
89
|
pattern = args.empty? ? "refs" : args.join("/")
|
103
|
-
exec("git
|
90
|
+
exec("git","for-each-ref", "--format=%(objectname) %(refname)", pattern) do |line|
|
104
91
|
yield *line.chomp.split(" ",2)
|
105
92
|
end
|
106
93
|
end
|
@@ -127,7 +114,7 @@ module Git
|
|
127
114
|
def config(arg1 = nil, arg2 = nil)
|
128
115
|
unless @config
|
129
116
|
@config = {}
|
130
|
-
exec("git
|
117
|
+
exec("git","config","-l") do |line|
|
131
118
|
key, value = line.chomp.split("=",2)
|
132
119
|
superkey, subkey = key.match(/(.*)\.(.*)/).to_a[1,2]
|
133
120
|
@config[superkey] ||= {}
|
@@ -212,7 +199,7 @@ module Git
|
|
212
199
|
return number.to_i
|
213
200
|
else
|
214
201
|
hash = generated_commits
|
215
|
-
exec("git
|
202
|
+
exec("git","rev-list", "--max-count=25", "HEAD") do |line|
|
216
203
|
number = hash[line.chomp] and return number
|
217
204
|
end
|
218
205
|
nil
|
data/lib/git/trac/runner.rb
CHANGED
@@ -75,7 +75,7 @@ Available commands:
|
|
75
75
|
|
76
76
|
def initialize(argv, repo)
|
77
77
|
@argv, @repository = argv, repo
|
78
|
-
@options = repo.config("trac")
|
78
|
+
@options = repo.config("trac") || {}
|
79
79
|
@opts = OptionParser.new
|
80
80
|
@opts.banner = "Usage: git-trac #{command} #{banner_arguments}\n#{"\n" if description}#{description}"
|
81
81
|
@opts.separator("")
|
@@ -242,15 +242,12 @@ potentially remove conflicted branches first.
|
|
242
242
|
opts.on("--[no-]local","don't run git-svn fetch") do |bool|
|
243
243
|
options[:local] = bool
|
244
244
|
end
|
245
|
-
opts.on("--[no-]update","run git-svn fetch (deprecated)") do |bool|
|
246
|
-
options[:local] = !bool
|
247
|
-
end
|
248
245
|
end
|
249
246
|
|
250
247
|
def run
|
251
248
|
unless options[:local]
|
252
249
|
@repository.in_work_tree do
|
253
|
-
system("git
|
250
|
+
system("git","svn","fetch")
|
254
251
|
end
|
255
252
|
end
|
256
253
|
each_ticket_argument do |number, filename|
|
@@ -336,23 +333,20 @@ it against a production trac server.
|
|
336
333
|
opts.on("--[no-]local","don't run git-svn fetch") do |bool|
|
337
334
|
options[:local] = bool
|
338
335
|
end
|
339
|
-
opts.on("--[no-]update","run git-svn fetch (deprecated)") do |bool|
|
340
|
-
options[:local] = !bool
|
341
|
-
end
|
342
336
|
end
|
343
337
|
|
344
338
|
def run
|
345
339
|
number = get_ticket_number
|
346
340
|
unless options[:local]
|
347
341
|
@repository.in_work_tree do
|
348
|
-
system("git
|
342
|
+
system("git","svn","fetch")
|
349
343
|
end
|
350
344
|
end
|
351
345
|
ticket = @repository.ticket(number)
|
352
346
|
if $stdin.tty? && !options[:force]
|
353
347
|
block = lambda do
|
354
348
|
@repository.in_work_tree do
|
355
|
-
system("git
|
349
|
+
system("git","diff", options[:branch] || "trunk...HEAD")
|
356
350
|
end
|
357
351
|
description = "##{number} (#{ticket.csv["summary"]}"
|
358
352
|
cols = ENV["COLUMNS"].to_i
|
data/lib/git/trac/ticket.rb
CHANGED
@@ -104,7 +104,7 @@ module Git
|
|
104
104
|
def upload_patch(options = {})
|
105
105
|
filename = options[:filename] || "#{File.basename(repository.current_checkout)}.patch"
|
106
106
|
# diff = repository.exec("git-diff","#{options[:branch] || "trunk"}...HEAD")
|
107
|
-
diff = repository.exec("git
|
107
|
+
diff = repository.exec("git","diff", options[:branch] || "trunk...HEAD")
|
108
108
|
return false if diff.empty?
|
109
109
|
# Don't upload the exact same patch that was pulled down
|
110
110
|
return false if repository.generated_commits[repository.rev_parse("HEAD")] == number
|
@@ -124,13 +124,13 @@ module Git
|
|
124
124
|
repository.each_ref("refs/remotes/trac/#{number}") do |object, ref|
|
125
125
|
if File.basename(ref) =~ /#{options[:filter]}/
|
126
126
|
revs << object
|
127
|
-
repository.exec("git
|
127
|
+
repository.exec("git","update-ref","-d",ref,object)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
unless revs.empty?
|
131
131
|
repository.each_ref("refs/heads") do |object, ref|
|
132
132
|
if revs.include?(object) && repository.current_checkout != File.basename(ref)
|
133
|
-
repository.exec("git
|
133
|
+
repository.exec("git","branch","-D",File.basename(ref))
|
134
134
|
end
|
135
135
|
end
|
136
136
|
true
|
@@ -145,13 +145,13 @@ module Git
|
|
145
145
|
attachments.select do |attachment|
|
146
146
|
attachment.filename =~ /#{options[:filter]}/
|
147
147
|
end.map do |attachment|
|
148
|
-
parent = repository.exec("git
|
149
|
-
repository.exec("git
|
148
|
+
parent = repository.exec("git","rev-list","--max-count=1","--before=#{attachment.timestamp}",options[:branch] || 'trunk').chomp
|
149
|
+
repository.exec("git","read-tree",parent)
|
150
150
|
unless attachment.apply(options)
|
151
151
|
yield attachment, false if block_given?
|
152
152
|
next
|
153
153
|
end
|
154
|
-
tree = repository.exec("git
|
154
|
+
tree = repository.exec("git","write-tree").chomp
|
155
155
|
ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] = attachment.username
|
156
156
|
ENV["GIT_AUTHOR_EMAIL"] = ENV["GIT_COMMITTER_EMAIL"] = attachment.email
|
157
157
|
ENV["GIT_AUTHOR_DATE"] = ENV["GIT_COMMITTER_DATE"] = attachment.timestamp
|
@@ -164,7 +164,7 @@ module Git
|
|
164
164
|
else
|
165
165
|
parents = " -p #{parent}"
|
166
166
|
end
|
167
|
-
commit = repository.popen3("git
|
167
|
+
commit = repository.popen3("git commit-tree #{tree}#{parents}") do |i,o,e|
|
168
168
|
i.puts "#{number}/#{attachment.filename}"
|
169
169
|
i.puts "\n#{attachment.description}" if attachment.description
|
170
170
|
i.close
|
data/test/execution_test.rb
CHANGED
@@ -16,12 +16,12 @@ class ExecutionTest < Test::Unit::TestCase
|
|
16
16
|
at_exit { FileUtils.rm_rf(directory) }
|
17
17
|
FileUtils.mkdir_p(directory)
|
18
18
|
Dir.chdir(directory) do
|
19
|
-
`git
|
19
|
+
`git init`
|
20
20
|
end
|
21
21
|
FileUtils.touch(File.join(directory,".gitignore"))
|
22
22
|
repo = Git::Trac::Repository.new(directory)
|
23
|
-
repo.exec("git
|
24
|
-
repo.exec("git
|
23
|
+
repo.exec("git","add",".gitignore")
|
24
|
+
repo.exec("git","commit","-m","Initial revision")
|
25
25
|
repo
|
26
26
|
end
|
27
27
|
|
@@ -34,15 +34,15 @@ class ExecutionTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_stderr_should_raise
|
37
|
-
assert_nothing_raised { @repo.exec("git
|
38
|
-
assert_raise(Git::Trac::ExecutionError) { @repo.exec("git
|
37
|
+
assert_nothing_raised { @repo.exec("git","diff","HEAD") }
|
38
|
+
assert_raise(Git::Trac::ExecutionError) { @repo.exec("git","diff","TAIL") }
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_should_determine_url
|
42
|
-
@repo.exec("git
|
42
|
+
@repo.exec("git","config","svn-remote.svn.url","http://dev.rubyonrails.org/svn/rails")
|
43
43
|
@repo.reload
|
44
44
|
assert_equal "http://dev.rubyonrails.org", @repo.url
|
45
|
-
@repo.exec("git
|
45
|
+
@repo.exec("git","config","trac.url","http://foo/trac.cgi")
|
46
46
|
@repo.reload
|
47
47
|
assert_equal "http://foo/trac.cgi", @repo.url
|
48
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-trac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20080204
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pope
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-02-04 00:00:00 -06:00
|
13
13
|
default_executable: git-trac
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|