rake_commit 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/rake_commit +2 -2
- data/lib/rake_commit/commit.rb +60 -0
- data/lib/rake_commit/commit_message.rb +16 -0
- data/lib/rake_commit/cruise_status.rb +27 -0
- data/lib/rake_commit/git.rb +92 -0
- data/lib/rake_commit/git_svn.rb +30 -0
- data/lib/rake_commit/prompt_line.rb +51 -0
- data/lib/rake_commit/shell.rb +16 -0
- data/lib/rake_commit/svn.rb +82 -0
- data/lib/rake_commit.rb +6 -0
- metadata +16 -13
- data/lib/commit.rb +0 -62
- data/lib/commit_message.rb +0 -14
- data/lib/cruise_status.rb +0 -25
- data/lib/git.rb +0 -90
- data/lib/git_svn.rb +0 -28
- data/lib/prompt_line.rb +0 -49
- data/lib/shell.rb +0 -14
- data/lib/svn.rb +0 -80
data/bin/rake_commit
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
module RakeCommit
|
5
|
+
class Commit
|
6
|
+
def git?
|
7
|
+
`git symbolic-ref HEAD 2>/dev/null`
|
8
|
+
$?.success?
|
9
|
+
end
|
10
|
+
|
11
|
+
def git_svn?
|
12
|
+
`git svn info 2> /dev/null`
|
13
|
+
$?.success?
|
14
|
+
end
|
15
|
+
|
16
|
+
def commit
|
17
|
+
options = {
|
18
|
+
:collapse_commits => true,
|
19
|
+
:incremental => false,
|
20
|
+
:prompt_exclusions => []
|
21
|
+
}
|
22
|
+
|
23
|
+
if File.exists?(".rake_commit")
|
24
|
+
defaults = File.read(".rake_commit")
|
25
|
+
options = parse_options(defaults.split(" "), options)
|
26
|
+
end
|
27
|
+
options = parse_options(ARGV, options)
|
28
|
+
|
29
|
+
if git_svn?
|
30
|
+
RakeCommit::GitSvn.new(options[:prompt_exclusions]).commit
|
31
|
+
elsif git?
|
32
|
+
RakeCommit::Git.new(options[:collapse_commits], options[:incremental], options[:prompt_exclusions]).commit
|
33
|
+
else
|
34
|
+
RakeCommit::Svn.new(options[:prompt_exclusions]).commit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_options(args, options)
|
39
|
+
parser = OptionParser.new do |opts|
|
40
|
+
opts.banner = "Usage: rake_commit [OPTIONS]"
|
41
|
+
opts.on("-h", "--help", "Show this message") do
|
42
|
+
puts opts
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
opts.on("-i", "--incremental", "Prompt for a local commit") do
|
46
|
+
options[:incremental] = true
|
47
|
+
end
|
48
|
+
opts.on("-n", "--no-collapse", "Run the build and push without collapsing commits") do
|
49
|
+
options[:collapse_commits] = false
|
50
|
+
end
|
51
|
+
opts.on("-w", "--without-prompt PROMPT", "Skips the given prompt (author, feature, message)") do |prompt_exclusion|
|
52
|
+
options[:prompt_exclusions] << prompt_exclusion
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
parser.parse(args)
|
57
|
+
options
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RakeCommit
|
2
|
+
class CommitMessage
|
3
|
+
|
4
|
+
attr_reader :pair, :feature, :message
|
5
|
+
|
6
|
+
def initialize(prompt_exclusions = [])
|
7
|
+
@pair = RakeCommit::PromptLine.new("pair", prompt_exclusions).prompt
|
8
|
+
@feature = RakeCommit::PromptLine.new("feature", prompt_exclusions).prompt
|
9
|
+
@message = RakeCommit::PromptLine.new("message", prompt_exclusions).prompt
|
10
|
+
end
|
11
|
+
|
12
|
+
def joined_message
|
13
|
+
[@pair, @feature, @message].compact.join(' - ')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require "open-uri"
|
3
|
+
|
4
|
+
module RakeCommit
|
5
|
+
class CruiseStatus
|
6
|
+
|
7
|
+
def initialize(feed_url)
|
8
|
+
project_feed = open(feed_url).read
|
9
|
+
@doc = REXML::Document.new(project_feed)
|
10
|
+
rescue Exception => e
|
11
|
+
@failures = [e.message]
|
12
|
+
@doc = REXML::Document.new("")
|
13
|
+
end
|
14
|
+
|
15
|
+
def pass?
|
16
|
+
failures.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
def failures
|
20
|
+
@failures ||= REXML::XPath.match(@doc, "//item/title").select { |element|
|
21
|
+
element.text =~ /failed$/
|
22
|
+
}.map do |element|
|
23
|
+
element.text.gsub( /(.*) build (.+) failed$/, '\1' )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module RakeCommit
|
2
|
+
class Git
|
3
|
+
|
4
|
+
def initialize(collapse_commits = true, incremental = false, prompt_exclusions = [])
|
5
|
+
@collapse_commits = collapse_commits
|
6
|
+
@incremental = incremental
|
7
|
+
@prompt_exclusions = prompt_exclusions
|
8
|
+
end
|
9
|
+
|
10
|
+
def commit
|
11
|
+
if @incremental
|
12
|
+
incremental_commit
|
13
|
+
else
|
14
|
+
collapse_git_commits if @collapse_commits && collapse_git_commits?
|
15
|
+
RakeCommit::Shell.system("rake")
|
16
|
+
push
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def collapse_git_commits?
|
21
|
+
return true unless merge_commits?
|
22
|
+
status
|
23
|
+
input = Readline.readline("Do you want to collapse merge commits? (y/n): ").chomp
|
24
|
+
input == "y"
|
25
|
+
end
|
26
|
+
|
27
|
+
def collapse_git_commits
|
28
|
+
add
|
29
|
+
temp_commit
|
30
|
+
reset_soft
|
31
|
+
status
|
32
|
+
return if nothing_to_commit?
|
33
|
+
incremental_commit
|
34
|
+
pull_rebase
|
35
|
+
end
|
36
|
+
|
37
|
+
def status
|
38
|
+
RakeCommit::Shell.system("git status", false)
|
39
|
+
end
|
40
|
+
|
41
|
+
def add
|
42
|
+
RakeCommit::Shell.system "git add -A ."
|
43
|
+
end
|
44
|
+
|
45
|
+
def incremental_commit
|
46
|
+
commit_message = RakeCommit::CommitMessage.new(@prompt_exclusions)
|
47
|
+
unless commit_message.pair.nil?
|
48
|
+
RakeCommit::Shell.system("git config user.name #{commit_message.pair.inspect}")
|
49
|
+
end
|
50
|
+
message = [commit_message.feature, commit_message.message].compact.join(" - ")
|
51
|
+
RakeCommit::Shell.system("git commit -m #{message.inspect}")
|
52
|
+
end
|
53
|
+
|
54
|
+
def reset_soft
|
55
|
+
raise "Could not determine branch" unless git_branch
|
56
|
+
RakeCommit::Shell.system "git reset --soft #{merge_base}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def pull_rebase
|
60
|
+
RakeCommit::Shell.system "git pull --rebase"
|
61
|
+
end
|
62
|
+
|
63
|
+
def push
|
64
|
+
RakeCommit::Shell.system "git push origin #{git_branch}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def temp_commit
|
68
|
+
return if nothing_to_commit?
|
69
|
+
RakeCommit::Shell.system "git commit -m 'rake_commit backup commit'"
|
70
|
+
end
|
71
|
+
|
72
|
+
def nothing_to_commit?
|
73
|
+
status = RakeCommit::Shell.backtick("git status", false)
|
74
|
+
status.empty? || status =~ /nothing to commit/m
|
75
|
+
end
|
76
|
+
|
77
|
+
def git_branch
|
78
|
+
@git_branch ||= begin
|
79
|
+
output = RakeCommit::Shell.backtick("git symbolic-ref HEAD")
|
80
|
+
output.gsub('refs/heads/', '').strip
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def merge_commits?
|
85
|
+
RakeCommit::Shell.backtick("git log #{merge_base}..HEAD") != RakeCommit::Shell.backtick("git log --no-merges #{merge_base}..HEAD")
|
86
|
+
end
|
87
|
+
|
88
|
+
def merge_base
|
89
|
+
@merge_base ||= RakeCommit::Shell.backtick("git merge-base #{git_branch} origin/#{git_branch}").strip
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RakeCommit
|
2
|
+
class GitSvn
|
3
|
+
def initialize(prompt_exclusions = [])
|
4
|
+
@prompt_exclusions = prompt_exclusions
|
5
|
+
end
|
6
|
+
|
7
|
+
def commit
|
8
|
+
git = RakeCommit::Git.new
|
9
|
+
git.add
|
10
|
+
git.status
|
11
|
+
git_svn_commit_with_message
|
12
|
+
rebase
|
13
|
+
RakeCommit::Shell.system "rake"
|
14
|
+
dcommit
|
15
|
+
end
|
16
|
+
|
17
|
+
def git_svn_commit_with_message
|
18
|
+
message = RakeCommit::CommitMessage.new(@prompt_exclusions).joined_message
|
19
|
+
RakeCommit::Shell.system "git commit -m #{message.inspect}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def rebase
|
23
|
+
RakeCommit::Shell.system "git svn rebase"
|
24
|
+
end
|
25
|
+
|
26
|
+
def dcommit
|
27
|
+
RakeCommit::Shell.system "git svn dcommit"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'readline'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module RakeCommit
|
5
|
+
class PromptLine
|
6
|
+
|
7
|
+
def initialize(attribute, prompt_exclusions = [])
|
8
|
+
@attribute = attribute
|
9
|
+
@prompt_exclusions = prompt_exclusions
|
10
|
+
end
|
11
|
+
|
12
|
+
def prompt
|
13
|
+
return nil if @prompt_exclusions.include?(@attribute)
|
14
|
+
input = nil
|
15
|
+
loop do
|
16
|
+
input = Readline.readline(message).chomp
|
17
|
+
break unless (input.empty? && saved_data.empty?)
|
18
|
+
end
|
19
|
+
|
20
|
+
unless input.empty?
|
21
|
+
save(input)
|
22
|
+
return input
|
23
|
+
end
|
24
|
+
|
25
|
+
puts "using: #{saved_data}"
|
26
|
+
return saved_data
|
27
|
+
end
|
28
|
+
|
29
|
+
def message
|
30
|
+
previous = saved_data
|
31
|
+
previous_message = "\n"
|
32
|
+
previous_message += "previous #{@attribute}: #{previous}\n" unless previous.empty?
|
33
|
+
puts previous_message
|
34
|
+
"#{@attribute}: "
|
35
|
+
end
|
36
|
+
|
37
|
+
def save(input)
|
38
|
+
File.open(path(@attribute), "w") {|f| f.write(input) }
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def saved_data
|
43
|
+
@saved_data ||= File.exists?(path(@attribute)) ? File.read(path(@attribute)) : ""
|
44
|
+
end
|
45
|
+
|
46
|
+
def path(attribute)
|
47
|
+
File.expand_path(Dir.tmpdir + "/#{attribute}.data")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'English'
|
2
|
+
|
3
|
+
module RakeCommit
|
4
|
+
class Shell
|
5
|
+
def self.system(cmd, raise_on_failure = true)
|
6
|
+
successful = Kernel.system(cmd)
|
7
|
+
raise if raise_on_failure && !successful
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.backtick(cmd, raise_on_failure = true)
|
11
|
+
output = `#{cmd}`
|
12
|
+
raise "Command failed: #{cmd.inspect}" if raise_on_failure && !$CHILD_STATUS.success?
|
13
|
+
output
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module RakeCommit
|
4
|
+
class Svn
|
5
|
+
|
6
|
+
def initialize(prompt_exclusions = [])
|
7
|
+
@prompt_exclusions = prompt_exclusions
|
8
|
+
end
|
9
|
+
|
10
|
+
def commit
|
11
|
+
if files_to_check_in?
|
12
|
+
message = RakeCommit::CommitMessage.new(@prompt_exclusions).joined_message
|
13
|
+
add
|
14
|
+
delete
|
15
|
+
up
|
16
|
+
RakeCommit::Shell.system "rake"
|
17
|
+
output = RakeCommit::Shell.backtick "#{commit_command(message)}"
|
18
|
+
puts output
|
19
|
+
revision = output.match(/Committed revision (\d+)\./)[1]
|
20
|
+
else
|
21
|
+
puts "Nothing to commit"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def commit_command(message)
|
26
|
+
"svn ci -m #{message.inspect}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def files_to_check_in?
|
30
|
+
RakeCommit::Shell.backtick("svn st --ignore-externals").split("\n").reject {|line| line[0,1] == "X"}.any?
|
31
|
+
end
|
32
|
+
|
33
|
+
def status
|
34
|
+
RakeCommit::Shell.system "svn st"
|
35
|
+
end
|
36
|
+
|
37
|
+
def up
|
38
|
+
output = RakeCommit::Shell.backtick "svn up"
|
39
|
+
puts output
|
40
|
+
output.split("\n").each do |line|
|
41
|
+
raise "SVN conflict detected. Please resolve conflicts before proceeding." if line[0,1] == "C"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def add
|
46
|
+
RakeCommit::Shell.backtick("svn st").split("\n").each do |line|
|
47
|
+
if new_file?(line) && !svn_conflict_file?(line)
|
48
|
+
file = line[7..-1].strip
|
49
|
+
RakeCommit::Shell.system "svn add #{file.inspect}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def new_file?(line)
|
55
|
+
line[0,1] == "?"
|
56
|
+
end
|
57
|
+
|
58
|
+
def svn_conflict_file?(line)
|
59
|
+
line =~ /\.r\d+$/ || line =~ /\.mine$/
|
60
|
+
end
|
61
|
+
|
62
|
+
def delete
|
63
|
+
RakeCommit::Shell.backtick("svn st").split("\n").each do |line|
|
64
|
+
if line[0,1] == "!"
|
65
|
+
file = line[7..-1].strip
|
66
|
+
RakeCommit::Shell.backtick "svn up #{file.inspect} && svn rm #{file.inspect}"
|
67
|
+
puts %[removed #{file}]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def revert_all
|
73
|
+
RakeCommit::Shell.system "svn revert -R ."
|
74
|
+
RakeCommit::Shell.backtick("svn st").split("\n").each do |line|
|
75
|
+
next unless line[0,1] == '?'
|
76
|
+
filename = line[1..-1].strip
|
77
|
+
puts "removed #{filename}"
|
78
|
+
FileUtils.rm_r filename
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/rake_commit.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake_commit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: See http://github.com/pgr0ss/rake_commit
|
15
15
|
email: pgross@gmail.com
|
@@ -20,16 +20,16 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- README.rdoc
|
22
22
|
- Rakefile
|
23
|
-
- lib/commit.rb
|
24
|
-
- lib/commit_message.rb
|
25
|
-
- lib/cruise_status.rb
|
26
|
-
- lib/git.rb
|
27
|
-
- lib/git_svn.rb
|
28
|
-
- lib/prompt_line.rb
|
29
|
-
- lib/shell.rb
|
30
|
-
- lib/svn.rb
|
31
|
-
-
|
32
|
-
|
23
|
+
- lib/rake_commit/commit.rb
|
24
|
+
- lib/rake_commit/commit_message.rb
|
25
|
+
- lib/rake_commit/cruise_status.rb
|
26
|
+
- lib/rake_commit/git.rb
|
27
|
+
- lib/rake_commit/git_svn.rb
|
28
|
+
- lib/rake_commit/prompt_line.rb
|
29
|
+
- lib/rake_commit/shell.rb
|
30
|
+
- lib/rake_commit/svn.rb
|
31
|
+
- lib/rake_commit.rb
|
32
|
+
- bin/rake_commit
|
33
33
|
homepage: http://github.com/pgr0ss/rake_commit
|
34
34
|
licenses: []
|
35
35
|
post_install_message:
|
@@ -42,6 +42,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- - ! '>='
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
hash: 3950958568738927598
|
45
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
49
|
none: false
|
47
50
|
requirements:
|
@@ -50,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
53
|
version: '0'
|
51
54
|
requirements: []
|
52
55
|
rubyforge_project: rake_commit
|
53
|
-
rubygems_version: 1.8.
|
56
|
+
rubygems_version: 1.8.24
|
54
57
|
signing_key:
|
55
58
|
specification_version: 3
|
56
59
|
summary: A gem which helps with checking in code
|
data/lib/commit.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'rexml/document'
|
3
|
-
|
4
|
-
Dir.glob(File.expand_path(File.dirname(__FILE__) + '/*.rb')) do |file|
|
5
|
-
require file
|
6
|
-
end
|
7
|
-
|
8
|
-
class Commit
|
9
|
-
def git?
|
10
|
-
`git symbolic-ref HEAD 2>/dev/null`
|
11
|
-
$?.success?
|
12
|
-
end
|
13
|
-
|
14
|
-
def git_svn?
|
15
|
-
`git svn info 2> /dev/null`
|
16
|
-
$?.success?
|
17
|
-
end
|
18
|
-
|
19
|
-
def commit
|
20
|
-
options = {
|
21
|
-
:collapse_commits => true,
|
22
|
-
:incremental => false,
|
23
|
-
:prompt_exclusions => []
|
24
|
-
}
|
25
|
-
|
26
|
-
if File.exists?(".rake_commit")
|
27
|
-
defaults = File.read(".rake_commit")
|
28
|
-
options = parse_options(defaults.split(" "), options)
|
29
|
-
end
|
30
|
-
options = parse_options(ARGV, options)
|
31
|
-
|
32
|
-
if git_svn?
|
33
|
-
GitSvn.new(options[:prompt_exclusions]).commit
|
34
|
-
elsif git?
|
35
|
-
Git.new(options[:collapse_commits], options[:incremental], options[:prompt_exclusions]).commit
|
36
|
-
else
|
37
|
-
Svn.new(options[:prompt_exclusions]).commit
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def parse_options(args, options)
|
42
|
-
parser = OptionParser.new do |opts|
|
43
|
-
opts.banner = "Usage: rake_commit [OPTIONS]"
|
44
|
-
opts.on("-h", "--help", "Show this message") do
|
45
|
-
puts opts
|
46
|
-
exit
|
47
|
-
end
|
48
|
-
opts.on("-i", "--incremental", "Prompt for a local commit") do
|
49
|
-
options[:incremental] = true
|
50
|
-
end
|
51
|
-
opts.on("-n", "--no-collapse", "Run the build and push without collapsing commits") do
|
52
|
-
options[:collapse_commits] = false
|
53
|
-
end
|
54
|
-
opts.on("-w", "--without-prompt PROMPT", "Skips the given prompt (author, feature, message)") do |prompt_exclusion|
|
55
|
-
options[:prompt_exclusions] << prompt_exclusion
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
parser.parse(args)
|
60
|
-
options
|
61
|
-
end
|
62
|
-
end
|
data/lib/commit_message.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
class CommitMessage
|
2
|
-
|
3
|
-
attr_reader :pair, :feature, :message
|
4
|
-
|
5
|
-
def initialize(prompt_exclusions = [])
|
6
|
-
@pair = PromptLine.new("pair", prompt_exclusions).prompt
|
7
|
-
@feature = PromptLine.new("feature", prompt_exclusions).prompt
|
8
|
-
@message = PromptLine.new("message", prompt_exclusions).prompt
|
9
|
-
end
|
10
|
-
|
11
|
-
def joined_message
|
12
|
-
[@pair, @feature, @message].compact.join(' - ')
|
13
|
-
end
|
14
|
-
end
|
data/lib/cruise_status.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
require "open-uri"
|
3
|
-
|
4
|
-
class CruiseStatus
|
5
|
-
|
6
|
-
def initialize(feed_url)
|
7
|
-
project_feed = open(feed_url).read
|
8
|
-
@doc = REXML::Document.new(project_feed)
|
9
|
-
rescue Exception => e
|
10
|
-
@failures = [e.message]
|
11
|
-
@doc = REXML::Document.new("")
|
12
|
-
end
|
13
|
-
|
14
|
-
def pass?
|
15
|
-
failures.empty?
|
16
|
-
end
|
17
|
-
|
18
|
-
def failures
|
19
|
-
@failures ||= REXML::XPath.match(@doc, "//item/title").select { |element|
|
20
|
-
element.text =~ /failed$/
|
21
|
-
}.map do |element|
|
22
|
-
element.text.gsub( /(.*) build (.+) failed$/, '\1' )
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/git.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
class Git
|
2
|
-
|
3
|
-
def initialize(collapse_commits = true, incremental = false, prompt_exclusions = [])
|
4
|
-
@collapse_commits = collapse_commits
|
5
|
-
@incremental = incremental
|
6
|
-
@prompt_exclusions = prompt_exclusions
|
7
|
-
end
|
8
|
-
|
9
|
-
def commit
|
10
|
-
if @incremental
|
11
|
-
incremental_commit
|
12
|
-
else
|
13
|
-
collapse_git_commits if @collapse_commits && collapse_git_commits?
|
14
|
-
Shell.system("rake")
|
15
|
-
push
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def collapse_git_commits?
|
20
|
-
return true unless merge_commits?
|
21
|
-
status
|
22
|
-
input = Readline.readline("Do you want to collapse merge commits? (y/n): ").chomp
|
23
|
-
input == "y"
|
24
|
-
end
|
25
|
-
|
26
|
-
def collapse_git_commits
|
27
|
-
add
|
28
|
-
temp_commit
|
29
|
-
reset_soft
|
30
|
-
status
|
31
|
-
return if nothing_to_commit?
|
32
|
-
incremental_commit
|
33
|
-
pull_rebase
|
34
|
-
end
|
35
|
-
|
36
|
-
def status
|
37
|
-
Shell.system("git status", false)
|
38
|
-
end
|
39
|
-
|
40
|
-
def add
|
41
|
-
Shell.system "git add -A ."
|
42
|
-
end
|
43
|
-
|
44
|
-
def incremental_commit
|
45
|
-
commit_message = CommitMessage.new(@prompt_exclusions)
|
46
|
-
unless commit_message.pair.nil?
|
47
|
-
Shell.system("git config user.name #{commit_message.pair.inspect}")
|
48
|
-
end
|
49
|
-
message = [commit_message.feature, commit_message.message].compact.join(" - ")
|
50
|
-
Shell.system("git commit -m #{message.inspect}")
|
51
|
-
end
|
52
|
-
|
53
|
-
def reset_soft
|
54
|
-
raise "Could not determine branch" unless git_branch
|
55
|
-
Shell.system "git reset --soft #{merge_base}"
|
56
|
-
end
|
57
|
-
|
58
|
-
def pull_rebase
|
59
|
-
Shell.system "git pull --rebase"
|
60
|
-
end
|
61
|
-
|
62
|
-
def push
|
63
|
-
Shell.system "git push origin #{git_branch}"
|
64
|
-
end
|
65
|
-
|
66
|
-
def temp_commit
|
67
|
-
return if nothing_to_commit?
|
68
|
-
Shell.system "git commit -m 'rake_commit backup commit'"
|
69
|
-
end
|
70
|
-
|
71
|
-
def nothing_to_commit?
|
72
|
-
status = Shell.backtick("git status", false)
|
73
|
-
status.empty? || status =~ /nothing to commit/m
|
74
|
-
end
|
75
|
-
|
76
|
-
def git_branch
|
77
|
-
@git_branch ||= begin
|
78
|
-
output = Shell.backtick("git symbolic-ref HEAD")
|
79
|
-
output.gsub('refs/heads/', '').strip
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def merge_commits?
|
84
|
-
Shell.backtick("git log #{merge_base}..HEAD") != Shell.backtick("git log --no-merges #{merge_base}..HEAD")
|
85
|
-
end
|
86
|
-
|
87
|
-
def merge_base
|
88
|
-
@merge_base ||= Shell.backtick("git merge-base #{git_branch} origin/#{git_branch}").strip
|
89
|
-
end
|
90
|
-
end
|
data/lib/git_svn.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class GitSvn
|
2
|
-
def initialize(prompt_exclusions = [])
|
3
|
-
@prompt_exclusions = prompt_exclusions
|
4
|
-
end
|
5
|
-
|
6
|
-
def commit
|
7
|
-
git = Git.new
|
8
|
-
git.add
|
9
|
-
git.status
|
10
|
-
git_svn_commit_with_message
|
11
|
-
rebase
|
12
|
-
Shell.system "rake"
|
13
|
-
dcommit
|
14
|
-
end
|
15
|
-
|
16
|
-
def git_svn_commit_with_message
|
17
|
-
message = CommitMessage.new(@prompt_exclusions).joined_message
|
18
|
-
Shell.system "git commit -m #{message.inspect}"
|
19
|
-
end
|
20
|
-
|
21
|
-
def rebase
|
22
|
-
Shell.system "git svn rebase"
|
23
|
-
end
|
24
|
-
|
25
|
-
def dcommit
|
26
|
-
Shell.system "git svn dcommit"
|
27
|
-
end
|
28
|
-
end
|
data/lib/prompt_line.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'readline'
|
2
|
-
require 'tmpdir'
|
3
|
-
|
4
|
-
class PromptLine
|
5
|
-
|
6
|
-
def initialize(attribute, prompt_exclusions = [])
|
7
|
-
@attribute = attribute
|
8
|
-
@prompt_exclusions = prompt_exclusions
|
9
|
-
end
|
10
|
-
|
11
|
-
def prompt
|
12
|
-
return nil if @prompt_exclusions.include?(@attribute)
|
13
|
-
input = nil
|
14
|
-
loop do
|
15
|
-
input = Readline.readline(message).chomp
|
16
|
-
break unless (input.empty? && saved_data.empty?)
|
17
|
-
end
|
18
|
-
|
19
|
-
unless input.empty?
|
20
|
-
save(input)
|
21
|
-
return input
|
22
|
-
end
|
23
|
-
|
24
|
-
puts "using: #{saved_data}"
|
25
|
-
return saved_data
|
26
|
-
end
|
27
|
-
|
28
|
-
def message
|
29
|
-
previous = saved_data
|
30
|
-
previous_message = "\n"
|
31
|
-
previous_message += "previous #{@attribute}: #{previous}\n" unless previous.empty?
|
32
|
-
puts previous_message
|
33
|
-
"#{@attribute}: "
|
34
|
-
end
|
35
|
-
|
36
|
-
def save(input)
|
37
|
-
File.open(path(@attribute), "w") {|f| f.write(input) }
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def saved_data
|
42
|
-
@saved_data ||= File.exists?(path(@attribute)) ? File.read(path(@attribute)) : ""
|
43
|
-
end
|
44
|
-
|
45
|
-
def path(attribute)
|
46
|
-
File.expand_path(Dir.tmpdir + "/#{attribute}.data")
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
data/lib/shell.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'English'
|
2
|
-
|
3
|
-
class Shell
|
4
|
-
def self.system(cmd, raise_on_failure = true)
|
5
|
-
successful = Kernel.system(cmd)
|
6
|
-
raise if raise_on_failure && !successful
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.backtick(cmd, raise_on_failure = true)
|
10
|
-
output = `#{cmd}`
|
11
|
-
raise "Command failed: #{cmd.inspect}" if raise_on_failure && !$CHILD_STATUS.success?
|
12
|
-
output
|
13
|
-
end
|
14
|
-
end
|
data/lib/svn.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
class Svn
|
4
|
-
|
5
|
-
def initialize(prompt_exclusions = [])
|
6
|
-
@prompt_exclusions = prompt_exclusions
|
7
|
-
end
|
8
|
-
|
9
|
-
def commit
|
10
|
-
if files_to_check_in?
|
11
|
-
message = CommitMessage.new(@prompt_exclusions).joined_message
|
12
|
-
add
|
13
|
-
delete
|
14
|
-
up
|
15
|
-
Shell.system "rake"
|
16
|
-
output = Shell.backtick "#{commit_command(message)}"
|
17
|
-
puts output
|
18
|
-
revision = output.match(/Committed revision (\d+)\./)[1]
|
19
|
-
else
|
20
|
-
puts "Nothing to commit"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def commit_command(message)
|
25
|
-
"svn ci -m #{message.inspect}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def files_to_check_in?
|
29
|
-
Shell.backtick("svn st --ignore-externals").split("\n").reject {|line| line[0,1] == "X"}.any?
|
30
|
-
end
|
31
|
-
|
32
|
-
def status
|
33
|
-
Shell.system "svn st"
|
34
|
-
end
|
35
|
-
|
36
|
-
def up
|
37
|
-
output = Shell.backtick "svn up"
|
38
|
-
puts output
|
39
|
-
output.split("\n").each do |line|
|
40
|
-
raise "SVN conflict detected. Please resolve conflicts before proceeding." if line[0,1] == "C"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def add
|
45
|
-
Shell.backtick("svn st").split("\n").each do |line|
|
46
|
-
if new_file?(line) && !svn_conflict_file?(line)
|
47
|
-
file = line[7..-1].strip
|
48
|
-
Shell.system "svn add #{file.inspect}"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def new_file?(line)
|
54
|
-
line[0,1] == "?"
|
55
|
-
end
|
56
|
-
|
57
|
-
def svn_conflict_file?(line)
|
58
|
-
line =~ /\.r\d+$/ || line =~ /\.mine$/
|
59
|
-
end
|
60
|
-
|
61
|
-
def delete
|
62
|
-
Shell.backtick("svn st").split("\n").each do |line|
|
63
|
-
if line[0,1] == "!"
|
64
|
-
file = line[7..-1].strip
|
65
|
-
Shell.backtick "svn up #{file.inspect} && svn rm #{file.inspect}"
|
66
|
-
puts %[removed #{file}]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def revert_all
|
72
|
-
Shell.system "svn revert -R ."
|
73
|
-
Shell.backtick("svn st").split("\n").each do |line|
|
74
|
-
next unless line[0,1] == '?'
|
75
|
-
filename = line[1..-1].strip
|
76
|
-
puts "removed #{filename}"
|
77
|
-
FileUtils.rm_r filename
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|