Skip to content

Commit 376bf13

Browse files
committed
Land rapid7#5000, tools/dev/add_pr_fetch.rb
2 parents 7bf00f8 + aa1a358 commit 376bf13

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tools/dev/add_pr_fetch.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
3+
toplevel = %x{git rev-parse --show-toplevel}.strip
4+
infile = "#{toplevel}/.git/config"
5+
outfile = infile
6+
$stderr.puts "Rewriting #{infile}"
7+
data = File.open(infile, 'rb') {|f| f.read f.stat.size}
8+
newdata = ""
9+
data.each_line do |line|
10+
newdata << line
11+
case line
12+
when /^(\s*)fetch\s*=.*remotes\/([^\/]+)\//
13+
ws = $1
14+
remote = $2
15+
pr_line = "fetch = +refs/pull/*/head:refs/remotes/#{remote}/pr/*"
16+
next if line.strip == pr_line.strip
17+
if data.include? pr_line
18+
$stderr.puts "Skipping #{remote}, already present"
19+
next
20+
else
21+
@new_pr_line ||= true
22+
$stderr.puts "Adding pull request fetch for #{remote}"
23+
newdata << "#{ws}#{pr_line}\n"
24+
end
25+
end
26+
end
27+
28+
if @new_pr_line
29+
File.open(outfile, 'wb') {|f| f.write newdata}
30+
$stderr.puts "Wrote #{outfile}"
31+
else
32+
$stderr.puts "No changes to #{outfile}"
33+
end

tools/dev/set_binary_encoding.rb

100644100755
File mode changed.

0 commit comments

Comments
 (0)