guitsaru-lighthouse_branch 1.0.0 → 1.1.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/README.rdoc +18 -5
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/lh-branch +1 -106
- data/bin/lhb +6 -0
- data/lib/lighthouse_branch.rb +66 -7
- data/lib/lighthouse_branch/command/base.rb +63 -0
- data/lib/lighthouse_branch/commands/branch.rb +16 -0
- data/lib/lighthouse_branch/commands/checkout.rb +12 -0
- data/lib/lighthouse_branch/commands/commit.rb +12 -0
- data/lib/lighthouse_branch/commands/delete.rb +17 -0
- data/lib/lighthouse_branch/commands/merge.rb +12 -0
- data/lib/lighthouse_branch/commands/pull.rb +12 -0
- data/lib/lighthouse_branch/commands/push.rb +12 -0
- data/lib/lighthouse_branch/commands/resolve.rb +11 -0
- data/lib/lighthouse_branch/commands/update.rb +16 -0
- data/lighthouse_branch.gemspec +84 -0
- data/test/command/test_base.rb +34 -0
- data/test/commands/test_branch.rb +17 -0
- data/test/commands/test_checkout.rb +11 -0
- data/test/commands/test_commit.rb +12 -0
- data/test/commands/test_delete.rb +16 -0
- data/test/commands/test_merge.rb +11 -0
- data/test/commands/test_pull.rb +11 -0
- data/test/commands/test_push.rb +11 -0
- data/test/commands/test_resolve.rb +12 -0
- data/test/commands/test_update.rb +17 -0
- metadata +37 -6
- data/test/test_lighthouse_branch.rb +0 -27
data/README.rdoc
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
= lighthouse_branch
|
2
2
|
|
3
|
+
= Installation
|
4
|
+
|
5
|
+
sudo gem install lighthouse_branch
|
6
|
+
|
3
7
|
= Setup
|
4
8
|
|
5
9
|
Add your Lighthouse project settings to your repo's git config.
|
@@ -10,13 +14,17 @@ Add your Lighthouse project settings to your repo's git config.
|
|
10
14
|
|
11
15
|
= Usage
|
12
16
|
|
13
|
-
|
17
|
+
If ticket_id is not given, it will be determined by the current branch.
|
18
|
+
This gem also comes with lhb, a shorter version of lh-branch
|
19
|
+
|
20
|
+
lh-branch [ticket_id] ([remote_name]): Creates a branch based on the ticket name.
|
21
|
+
If remote_name is given, the branch will be pushed to the remote.
|
14
22
|
lh-branch 1 #=> git checkout -b 1-ticket-title
|
15
23
|
|
16
|
-
lh-branch push [ticket_id] [
|
24
|
+
lh-branch push [ticket_id] [remote_name]: Pushes the ticket's branch to the named remote.
|
17
25
|
lh-branch 1 origin #=> git push origin 1-ticket-title
|
18
26
|
|
19
|
-
lh-branch pull [ticket_id] [
|
27
|
+
lh-branch pull [ticket_id] [remote_name]: Pulls the ticket's branch from the named remote.
|
20
28
|
lh-branch 1 origin #=> git pull origin 1-ticket-title
|
21
29
|
|
22
30
|
lh-branch merge [ticket_id]: Merges the ticket's branch with the current branch.
|
@@ -25,10 +33,15 @@ lh-branch merge [ticket_id]: Merges the ticket's branch with the current branch.
|
|
25
33
|
lh-branch checkout [ticket_id]: Checks out the ticket's branch, making it the current branch.
|
26
34
|
lh-branch checkout 1 #=> git checkout 1-ticket-title
|
27
35
|
|
28
|
-
lh-branch delete [ticket_id]: Deletes the ticket's branch.
|
36
|
+
lh-branch delete [ticket_id] ([remote_name]): Deletes the ticket's branch.
|
37
|
+
If remote_name is given, the branch will also be deleted on remote.
|
29
38
|
lh-branch delete 1 #=> git branch -d 1-ticket-title
|
30
39
|
|
31
|
-
lh-branch
|
40
|
+
lh-branch update [ticket_id] [message] ([extra]): Creates a commit that references the ticket
|
41
|
+
Extra is any extra lighthouse commands
|
42
|
+
lh-branch update 1 "Made some changes" #=> git commit -a -m "Made some changes\n\n[#1 tagged:'branch:1-ticket-title']"
|
43
|
+
|
44
|
+
lh-branch resolve [ticket_id] [message]: Creates a commit that will mark the ticket resolved.
|
32
45
|
lh-branch resolve 1 "Fixed the bug." #=> git commit -a -m "Fixed the bug\n\n[#1 state:resolved]"
|
33
46
|
|
34
47
|
== Copyright
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gem.email = "guitsaru@gmail.com"
|
10
10
|
gem.homepage = "http://github.com/guitsaru/lighthouse_branch"
|
11
11
|
gem.authors = ["Matt Pruitt"]
|
12
|
-
gem.rubyforge_project = "
|
12
|
+
gem.rubyforge_project = "lh-branch"
|
13
13
|
gem.add_dependency('grit', '>= 1.1.1')
|
14
14
|
gem.add_dependency('Caged-lighthouse-api', '>= 1.0.0')
|
15
15
|
end
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
require 'rake/testtask'
|
23
23
|
Rake::TestTask.new(:test) do |test|
|
24
24
|
test.libs << 'lib' << 'test'
|
25
|
-
test.pattern = 'test
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
26
|
test.verbose = true
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ begin
|
|
30
30
|
require 'rcov/rcovtask'
|
31
31
|
Rcov::RcovTask.new do |test|
|
32
32
|
test.libs << 'test'
|
33
|
-
test.pattern = 'test
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
34
|
test.verbose = true
|
35
35
|
end
|
36
36
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/bin/lh-branch
CHANGED
@@ -2,110 +2,5 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'lighthouse_branch')
|
5
|
-
require 'grit'
|
6
5
|
|
7
|
-
|
8
|
-
case args[0]
|
9
|
-
when nil
|
10
|
-
return nil
|
11
|
-
when /push/i
|
12
|
-
args.shift
|
13
|
-
return 'push'
|
14
|
-
when /pull/i
|
15
|
-
args.shift
|
16
|
-
return 'pull'
|
17
|
-
when /merge/i
|
18
|
-
args.shift
|
19
|
-
return 'merge'
|
20
|
-
when /checkout/i
|
21
|
-
args.shift
|
22
|
-
return 'checkout'
|
23
|
-
when /delete/i
|
24
|
-
args.shift
|
25
|
-
return 'delete'
|
26
|
-
when /resolve/i
|
27
|
-
args.shift
|
28
|
-
return 'resolve'
|
29
|
-
else return 'branch'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def get_lighthouse_branch
|
34
|
-
repo = Grit::Repo.new(Dir.pwd)
|
35
|
-
|
36
|
-
lighthouse_account = repo.config["lighthouse.account"]
|
37
|
-
lighthouse_token = repo.config["lighthouse.token"]
|
38
|
-
lighthouse_project = repo.config["lighthouse.project"]
|
39
|
-
|
40
|
-
if lighthouse_account.nil? || lighthouse_token.nil? || lighthouse_project.nil?
|
41
|
-
puts "You must add your lighthouse account info to git config:"
|
42
|
-
puts "git config lighthouse.account [lighthouse account subdomain]"
|
43
|
-
puts "git config lighthouse.token [lighthouse API token]"
|
44
|
-
puts "git config lighthouse.project [lighthouse project id]"
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
|
48
|
-
return LighthouseBranch.new(lighthouse_account, lighthouse_token, lighthouse_project)
|
49
|
-
end
|
50
|
-
|
51
|
-
args = ARGV
|
52
|
-
|
53
|
-
command = get_command(args)
|
54
|
-
ticket_id = args.shift.to_i
|
55
|
-
command = nil if ticket_id == 0
|
56
|
-
|
57
|
-
lighthouse_branch = get_lighthouse_branch
|
58
|
-
|
59
|
-
case command
|
60
|
-
when nil
|
61
|
-
puts "Usage:"
|
62
|
-
puts "lh-branch [ticket_id]"
|
63
|
-
puts "lh-branch push [ticket_id] [remote name]"
|
64
|
-
puts "lh-branch pull [ticket_id] [remote name]"
|
65
|
-
puts "lh-branch merge [ticket_id]"
|
66
|
-
puts "lh-branch checkout [ticket_id]"
|
67
|
-
puts "lh-branch delete [ticket_id]"
|
68
|
-
puts "lh-branch resolve 1 [message]"
|
69
|
-
when 'branch'
|
70
|
-
if args.size != 0
|
71
|
-
puts "Usage: lh-branch [ticket_id]"
|
72
|
-
exit
|
73
|
-
end
|
74
|
-
system("git checkout -b #{lighthouse_branch.branch_name(ticket_id)}")
|
75
|
-
when 'delete'
|
76
|
-
if args.size != 0
|
77
|
-
puts "Usage: lh-branch delete [ticket_id]"
|
78
|
-
exit
|
79
|
-
end
|
80
|
-
system("git branch -d #{lighthouse_branch.branch_name(ticket_id)}")
|
81
|
-
when 'push'
|
82
|
-
if args.size != 1
|
83
|
-
puts "Usage: lh-branch push [ticket_id] [remote name]"
|
84
|
-
exit
|
85
|
-
end
|
86
|
-
system("git push #{args.shift} #{lighthouse_branch.branch_name(ticket_id)}")
|
87
|
-
when 'pull'
|
88
|
-
if args.size != 1
|
89
|
-
puts "Usage: lh-branch pull [ticket_id] [remote name]"
|
90
|
-
exit
|
91
|
-
end
|
92
|
-
system("git pull #{args.shift} #{lighthouse_branch.branch_name(ticket_id)}")
|
93
|
-
when 'checkout'
|
94
|
-
if args.size != 0
|
95
|
-
puts "Usage: lh-branch checkout [ticket_id]"
|
96
|
-
exit
|
97
|
-
end
|
98
|
-
system("git checkout #{lighthouse_branch.branch_name(ticket_id)}")
|
99
|
-
when 'merge'
|
100
|
-
if args.size != 0
|
101
|
-
puts "Usage: lh-branch merge [ticket_id]"
|
102
|
-
exit
|
103
|
-
end
|
104
|
-
system("git merge #{lighthouse_branch.branch_name(ticket_id)}")
|
105
|
-
when 'resolve'
|
106
|
-
if args.size != 1
|
107
|
-
puts "Usage: lh-branch resolve 1 [message]"
|
108
|
-
exit
|
109
|
-
end
|
110
|
-
system("git commit -a -m \"#{args.shift}\n\n[##{ticket_id} state:resolved]\"")
|
111
|
-
end
|
6
|
+
LighthouseBranch.invoke(ARGV)
|
data/bin/lhb
ADDED
data/lib/lighthouse_branch.rb
CHANGED
@@ -1,17 +1,76 @@
|
|
1
1
|
require 'lighthouse-api'
|
2
|
+
require 'grit'
|
3
|
+
require File.join(File.dirname(__FILE__), 'lighthouse_branch', 'command', 'base')
|
4
|
+
|
5
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'lighthouse_branch', 'commands', '**.rb')).each { |command| require command }
|
2
6
|
|
3
7
|
class LighthouseBranch
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
def self.repo
|
9
|
+
@repo ||= Grit::Repo.new(Dir.pwd)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get_lighthouse_account
|
13
|
+
Lighthouse.account = repo.config["lighthouse.account"]
|
14
|
+
Lighthouse.token = repo.config["lighthouse.token"]
|
15
|
+
|
16
|
+
begin
|
17
|
+
@project = Lighthouse::Project.find(repo.config["lighthouse.project"])
|
18
|
+
rescue
|
19
|
+
puts "You must add your lighthouse account info to git config:"
|
20
|
+
puts "git config lighthouse.account [lighthouse account subdomain]"
|
21
|
+
puts "git config lighthouse.token [lighthouse API token]"
|
22
|
+
puts "git config lighthouse.project [lighthouse project id]"
|
23
|
+
exit
|
24
|
+
end
|
8
25
|
end
|
9
26
|
|
10
|
-
def ticket(id)
|
27
|
+
def self.ticket(id)
|
11
28
|
Lighthouse::Ticket.find(id, :params => { :project_id => @project.id })
|
12
29
|
end
|
13
30
|
|
14
|
-
def branch_name(
|
15
|
-
|
31
|
+
def self.branch_name(args)
|
32
|
+
unless @branch_name
|
33
|
+
if(Float(args.first) rescue false)
|
34
|
+
ticket_id = args.shift.to_i
|
35
|
+
@branch_name = "#{ticket_id}-#{ticket(ticket_id).title.gsub(/[^\w ]/, '').gsub(/[^a-z0-9]+/i, '-').downcase}"
|
36
|
+
else
|
37
|
+
@branch_name = repo.head.name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
return @branch_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.invoke(args)
|
45
|
+
get_lighthouse_account
|
46
|
+
|
47
|
+
command = :default
|
48
|
+
if Command::Base.command_regexes.select{ |command| args.first =~ command }.empty?
|
49
|
+
branch = branch_name(args)
|
50
|
+
ticket_id = branch.to_i
|
51
|
+
if ticket_id == 0
|
52
|
+
usage
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
else
|
56
|
+
command = args.shift
|
57
|
+
branch = branch_name(args)
|
58
|
+
ticket_id = branch.to_i
|
59
|
+
end
|
60
|
+
|
61
|
+
Command::Base.invoke(command, branch, ticket_id, args)
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.usage
|
65
|
+
puts "If ticket_id is not supplied, the ticket will be determined by the current branch name."
|
66
|
+
puts "lh-branch [ticket_id] ([remote_name])"
|
67
|
+
puts "lh-branch push [ticket_id] [remote_name]"
|
68
|
+
puts "lh-branch pull [ticket_id] [remote_name]"
|
69
|
+
puts "lh-branch merge [ticket_id]"
|
70
|
+
puts "lh-branch checkout [ticket_id]"
|
71
|
+
puts "lh-branch update [ticket_id] [message] ([extra])"
|
72
|
+
puts "lh-branch delete [ticket_id] ([remote_name])"
|
73
|
+
puts "lh-branch delete_remote [ticket_id] [remote_name]"
|
74
|
+
puts "lh-branch resolve [ticket_id] [message]"
|
16
75
|
end
|
17
76
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Command
|
2
|
+
class Base
|
3
|
+
@@commands = {}
|
4
|
+
|
5
|
+
def self.default_command
|
6
|
+
@@commands.merge!(:default => self)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.command_name(name)
|
10
|
+
name = name.to_s.downcase.to_sym
|
11
|
+
@@commands.merge!(name => self)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.number_of_arguments(arguments)
|
15
|
+
self.class_eval("@@number_of_arguments = #{arguments}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.usage(usage=nil)
|
19
|
+
if usage
|
20
|
+
return self.class_eval("@@usage = \"#{usage}\"")
|
21
|
+
else
|
22
|
+
return self.class_eval("@@usage")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.commands
|
27
|
+
return @@commands
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.run(lighthouse_branch, ticket, args)
|
31
|
+
return unless defined?(:command_string)
|
32
|
+
|
33
|
+
number_of_arguments = (self.class_eval("@@number_of_arguments") || 0)
|
34
|
+
|
35
|
+
correct_arguments = false
|
36
|
+
if number_of_arguments.is_a?(Range)
|
37
|
+
correct_arguments = number_of_arguments.member?(args.size)
|
38
|
+
elsif number_of_arguments.is_a?(Fixnum)
|
39
|
+
correct_arguments = (number_of_arguments == args.size)
|
40
|
+
end
|
41
|
+
|
42
|
+
if correct_arguments
|
43
|
+
system(self.command_string(lighthouse_branch, ticket, args))
|
44
|
+
else
|
45
|
+
puts self.usage and exit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.command_regexes
|
50
|
+
@@commands.keys.map { |k| /#{k}/i }
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.invoke(command, branch_name, ticket_id, args)
|
54
|
+
command = @@commands[command.to_s.downcase.to_sym]
|
55
|
+
if !command
|
56
|
+
command = @@commands[:default]
|
57
|
+
end
|
58
|
+
|
59
|
+
return nil if ticket_id <= 0
|
60
|
+
command.run(branch_name, ticket_id, args)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Command
|
2
|
+
class Branch < Command::Base
|
3
|
+
default_command
|
4
|
+
number_of_arguments (0..1)
|
5
|
+
|
6
|
+
usage "lh-branch [ticket_id]"
|
7
|
+
|
8
|
+
def self.command_string(branch_name, ticket_id, args)
|
9
|
+
command_string = "git checkout -b #{branch_name}"
|
10
|
+
if remote_name = args.shift
|
11
|
+
command_string += "; #{Command::Push.command_string(branch_name, ticket_id, remote_name.to_a)}"
|
12
|
+
end
|
13
|
+
return command_string
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Command
|
2
|
+
class Commit < Command::Base
|
3
|
+
command_name :commit
|
4
|
+
number_of_arguments 1
|
5
|
+
|
6
|
+
usage "lh-branch commit [ticket_id] [message]"
|
7
|
+
|
8
|
+
def self.command_string(branch_name, ticket_id, args)
|
9
|
+
"git commit -a -m \"#{args.shift}\n\n[##{ticket_id}]\""
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Command
|
2
|
+
class Delete < Command::Base
|
3
|
+
command_name :delete
|
4
|
+
number_of_arguments (0..1)
|
5
|
+
|
6
|
+
usage "lh-branch delete [ticket_id] ([remote_name])"
|
7
|
+
|
8
|
+
def self.command_string(branch_name, ticket_id, args)
|
9
|
+
command_string = "git branch -d #{branch_name}"
|
10
|
+
if !args.empty?
|
11
|
+
remote_name = args.shift
|
12
|
+
command_string +="; git push #{remote_name} :#{branch_name}"
|
13
|
+
end
|
14
|
+
return command_string
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Command
|
2
|
+
class Pull < Command::Base
|
3
|
+
command_name :pull
|
4
|
+
number_of_arguments 1
|
5
|
+
|
6
|
+
usage "lh-branch pull [ticket_id] [remote_name]"
|
7
|
+
|
8
|
+
def self.command_string(branch_name, ticket_id, args)
|
9
|
+
"git pull #{args.shift} #{branch_name}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Command
|
2
|
+
class Push < Command::Base
|
3
|
+
command_name :push
|
4
|
+
number_of_arguments 1
|
5
|
+
|
6
|
+
usage "lh-branch push [ticket_id] [remote_name]"
|
7
|
+
|
8
|
+
def self.command_string(branch_name, ticket_id, args)
|
9
|
+
"git push #{args.shift} #{branch_name}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Command
|
2
|
+
class Resolve < Command::Base
|
3
|
+
command_name :resolve
|
4
|
+
number_of_arguments 1
|
5
|
+
usage "lh-branch resolve [ticket_id] [message]"
|
6
|
+
|
7
|
+
def self.command_string(branch_name, ticket_id, args)
|
8
|
+
"git commit -a -m \"#{args.shift}\n\n[##{ticket_id} state:resolved]\""
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Command
|
2
|
+
class Update < Command::Base
|
3
|
+
command_name :update
|
4
|
+
number_of_arguments (1..2)
|
5
|
+
|
6
|
+
usage "lh-branch update [ticket_id] [message]"
|
7
|
+
|
8
|
+
def self.command_string(branch_name, ticket_id, args)
|
9
|
+
msg = args.shift
|
10
|
+
extra = ""
|
11
|
+
extra = " #{args.shift}".rstrip unless args.empty?
|
12
|
+
|
13
|
+
"git commit -a -m \"#{msg}\n\n[##{ticket_id} tagged:'branch:#{branch_name}'#{extra}]\""
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{lighthouse_branch}
|
5
|
+
s.version = "1.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Matt Pruitt"]
|
9
|
+
s.date = %q{2009-06-23}
|
10
|
+
s.email = %q{guitsaru@gmail.com}
|
11
|
+
s.executables = ["lh-branch", "lhb"]
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.rdoc"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".document",
|
18
|
+
".gitignore",
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"bin/lh-branch",
|
24
|
+
"bin/lhb",
|
25
|
+
"lib/lighthouse_branch.rb",
|
26
|
+
"lib/lighthouse_branch/command/base.rb",
|
27
|
+
"lib/lighthouse_branch/commands/branch.rb",
|
28
|
+
"lib/lighthouse_branch/commands/checkout.rb",
|
29
|
+
"lib/lighthouse_branch/commands/commit.rb",
|
30
|
+
"lib/lighthouse_branch/commands/delete.rb",
|
31
|
+
"lib/lighthouse_branch/commands/merge.rb",
|
32
|
+
"lib/lighthouse_branch/commands/pull.rb",
|
33
|
+
"lib/lighthouse_branch/commands/push.rb",
|
34
|
+
"lib/lighthouse_branch/commands/resolve.rb",
|
35
|
+
"lib/lighthouse_branch/commands/update.rb",
|
36
|
+
"lighthouse_branch.gemspec",
|
37
|
+
"test/command/test_base.rb",
|
38
|
+
"test/commands/test_branch.rb",
|
39
|
+
"test/commands/test_checkout.rb",
|
40
|
+
"test/commands/test_commit.rb",
|
41
|
+
"test/commands/test_delete.rb",
|
42
|
+
"test/commands/test_merge.rb",
|
43
|
+
"test/commands/test_pull.rb",
|
44
|
+
"test/commands/test_push.rb",
|
45
|
+
"test/commands/test_resolve.rb",
|
46
|
+
"test/commands/test_update.rb",
|
47
|
+
"test/test_helper.rb"
|
48
|
+
]
|
49
|
+
s.homepage = %q{http://github.com/guitsaru/lighthouse_branch}
|
50
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
s.rubyforge_project = %q{lh-branch}
|
53
|
+
s.rubygems_version = %q{1.3.4}
|
54
|
+
s.summary = %q{Easily manage branches based off lighthouse tickets.}
|
55
|
+
s.test_files = [
|
56
|
+
"test/command/test_base.rb",
|
57
|
+
"test/commands/test_branch.rb",
|
58
|
+
"test/commands/test_checkout.rb",
|
59
|
+
"test/commands/test_commit.rb",
|
60
|
+
"test/commands/test_delete.rb",
|
61
|
+
"test/commands/test_merge.rb",
|
62
|
+
"test/commands/test_pull.rb",
|
63
|
+
"test/commands/test_push.rb",
|
64
|
+
"test/commands/test_resolve.rb",
|
65
|
+
"test/commands/test_update.rb",
|
66
|
+
"test/test_helper.rb"
|
67
|
+
]
|
68
|
+
|
69
|
+
if s.respond_to? :specification_version then
|
70
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
71
|
+
s.specification_version = 3
|
72
|
+
|
73
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
74
|
+
s.add_runtime_dependency(%q<grit>, [">= 1.1.1"])
|
75
|
+
s.add_runtime_dependency(%q<Caged-lighthouse-api>, [">= 1.0.0"])
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<grit>, [">= 1.1.1"])
|
78
|
+
s.add_dependency(%q<Caged-lighthouse-api>, [">= 1.0.0"])
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s.add_dependency(%q<grit>, [">= 1.1.1"])
|
82
|
+
s.add_dependency(%q<Caged-lighthouse-api>, [">= 1.0.0"])
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Command
|
4
|
+
class Base
|
5
|
+
@@commands = {}
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class DefaultCommand < Command::Base
|
10
|
+
default_command
|
11
|
+
end
|
12
|
+
|
13
|
+
class NamedCommand < Command::Base
|
14
|
+
command_name :named
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestCommandBase < Test::Unit::TestCase
|
18
|
+
should "include a list of empty commands on initialization" do
|
19
|
+
assert(Command::Base.commands.is_a?(Hash), "Commands is not a hash.")
|
20
|
+
end
|
21
|
+
|
22
|
+
should "add a default command" do
|
23
|
+
assert_equal(DefaultCommand, Command::Base.commands[:default])
|
24
|
+
end
|
25
|
+
|
26
|
+
should "add a named command" do
|
27
|
+
assert_equal(NamedCommand, Command::Base.commands[:named])
|
28
|
+
end
|
29
|
+
|
30
|
+
should "have a list of regexes to match" do
|
31
|
+
assert(Command::Base.command_regexes.include?(/named/i))
|
32
|
+
assert(Command::Base.command_regexes.include?(/default/i))
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestBranchCommand < Test::Unit::TestCase
|
4
|
+
should "create the branch with no arguments" do
|
5
|
+
assert_equal("git checkout -b 1-test-ticket", \
|
6
|
+
Command::Branch.command_string('1-test-ticket', 1, []))
|
7
|
+
end
|
8
|
+
|
9
|
+
should "create the branch and push to remote with an argument" do
|
10
|
+
assert_equal("git checkout -b 1-test-ticket; git push origin 1-test-ticket",
|
11
|
+
Command::Branch.command_string('1-test-ticket', 1, ['origin']))
|
12
|
+
end
|
13
|
+
|
14
|
+
should "have usage instructions" do
|
15
|
+
assert_equal("lh-branch [ticket_id]", Command::Branch.usage)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestCheckoutCommand < Test::Unit::TestCase
|
4
|
+
should "check out the branch" do
|
5
|
+
assert_equal("git checkout 1-test-ticket", Command::Checkout.command_string('1-test-ticket', 1, []))
|
6
|
+
end
|
7
|
+
|
8
|
+
should "have usage instructions" do
|
9
|
+
assert_equal("lh-branch checkout [ticket_id]", Command::Checkout.usage)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestBranchCommit < Test::Unit::TestCase
|
4
|
+
should "Commit the branch" do
|
5
|
+
assert_equal("git commit -a -m \"Message\n\n[#1]\"",
|
6
|
+
Command::Commit.command_string('1-test-ticket', 1, ['Message']))
|
7
|
+
end
|
8
|
+
|
9
|
+
should "have usage instructions" do
|
10
|
+
assert_equal("lh-branch commit [ticket_id] [message]", Command::Commit.usage)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestDeleteCommand < Test::Unit::TestCase
|
4
|
+
should "delete the branch with no origin name" do
|
5
|
+
assert_equal("git branch -d 1-test-ticket", Command::Delete.command_string('1-test-ticket', 1, []))
|
6
|
+
end
|
7
|
+
|
8
|
+
should "delete the branch with an origin name" do
|
9
|
+
assert_equal("git branch -d 1-test-ticket; git push origin :1-test-ticket",
|
10
|
+
Command::Delete.command_string('1-test-ticket', 1, ['origin']))
|
11
|
+
end
|
12
|
+
|
13
|
+
should "have usage instructions" do
|
14
|
+
assert_equal("lh-branch delete [ticket_id] ([remote_name])", Command::Delete.usage)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestMergeCommand < Test::Unit::TestCase
|
4
|
+
should "merge out the branch" do
|
5
|
+
assert_equal("git merge 1-test-ticket", Command::Merge.command_string('1-test-ticket', 1, []))
|
6
|
+
end
|
7
|
+
|
8
|
+
should "have usage instructions" do
|
9
|
+
assert_equal("lh-branch merge [ticket_id]", Command::Merge.usage)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestPullCommand < Test::Unit::TestCase
|
4
|
+
should "pull out the branch" do
|
5
|
+
assert_equal("git pull origin 1-test-ticket", Command::Pull.command_string('1-test-ticket', 1, ['origin']))
|
6
|
+
end
|
7
|
+
|
8
|
+
should "have usage instructions" do
|
9
|
+
assert_equal("lh-branch pull [ticket_id] [remote_name]", Command::Pull.usage)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestPushCommand < Test::Unit::TestCase
|
4
|
+
should "pull out the branch" do
|
5
|
+
assert_equal("git push origin 1-test-ticket", Command::Push.command_string('1-test-ticket', 1, ['origin']))
|
6
|
+
end
|
7
|
+
|
8
|
+
should "have usage instructions" do
|
9
|
+
assert_equal("lh-branch push [ticket_id] [remote_name]", Command::Push.usage)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestResolveCommand < Test::Unit::TestCase
|
4
|
+
should "resolve the ticket" do
|
5
|
+
assert_equal("git commit -a -m \"Message.\n\n[#1 state:resolved]\"",
|
6
|
+
Command::Resolve.command_string('1-test-ticket', 1, ['Message.']))
|
7
|
+
end
|
8
|
+
|
9
|
+
should "have usage instructions" do
|
10
|
+
assert_equal("lh-branch resolve [ticket_id] [message]", Command::Resolve.usage)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestBranchUpdate < Test::Unit::TestCase
|
4
|
+
should "Update the ticket" do
|
5
|
+
assert_equal("git commit -a -m \"Message.\n\n[#1 tagged:'branch:1-test-ticket']\"",
|
6
|
+
Command::Update.command_string('1-test-ticket', 1, ['Message.']))
|
7
|
+
end
|
8
|
+
|
9
|
+
should "Update the ticket with extra" do
|
10
|
+
assert_equal("git commit -a -m \"Message.\n\n[#1 tagged:'branch:1-test-ticket' milestone:'next milestone']\"",
|
11
|
+
Command::Update.command_string('1-test-ticket', 1, ['Message.', "milestone:'next milestone'"]))
|
12
|
+
end
|
13
|
+
|
14
|
+
should "have usage instructions" do
|
15
|
+
assert_equal("lh-branch update [ticket_id] [message]", Command::Update.usage)
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guitsaru-lighthouse_branch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Pruitt
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-06-23 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: grit
|
@@ -36,6 +36,7 @@ description:
|
|
36
36
|
email: guitsaru@gmail.com
|
37
37
|
executables:
|
38
38
|
- lh-branch
|
39
|
+
- lhb
|
39
40
|
extensions: []
|
40
41
|
|
41
42
|
extra_rdoc_files:
|
@@ -49,9 +50,30 @@ files:
|
|
49
50
|
- Rakefile
|
50
51
|
- VERSION
|
51
52
|
- bin/lh-branch
|
53
|
+
- bin/lhb
|
52
54
|
- lib/lighthouse_branch.rb
|
55
|
+
- lib/lighthouse_branch/command/base.rb
|
56
|
+
- lib/lighthouse_branch/commands/branch.rb
|
57
|
+
- lib/lighthouse_branch/commands/checkout.rb
|
58
|
+
- lib/lighthouse_branch/commands/commit.rb
|
59
|
+
- lib/lighthouse_branch/commands/delete.rb
|
60
|
+
- lib/lighthouse_branch/commands/merge.rb
|
61
|
+
- lib/lighthouse_branch/commands/pull.rb
|
62
|
+
- lib/lighthouse_branch/commands/push.rb
|
63
|
+
- lib/lighthouse_branch/commands/resolve.rb
|
64
|
+
- lib/lighthouse_branch/commands/update.rb
|
65
|
+
- lighthouse_branch.gemspec
|
66
|
+
- test/command/test_base.rb
|
67
|
+
- test/commands/test_branch.rb
|
68
|
+
- test/commands/test_checkout.rb
|
69
|
+
- test/commands/test_commit.rb
|
70
|
+
- test/commands/test_delete.rb
|
71
|
+
- test/commands/test_merge.rb
|
72
|
+
- test/commands/test_pull.rb
|
73
|
+
- test/commands/test_push.rb
|
74
|
+
- test/commands/test_resolve.rb
|
75
|
+
- test/commands/test_update.rb
|
53
76
|
- test/test_helper.rb
|
54
|
-
- test/test_lighthouse_branch.rb
|
55
77
|
has_rdoc: false
|
56
78
|
homepage: http://github.com/guitsaru/lighthouse_branch
|
57
79
|
post_install_message:
|
@@ -73,11 +95,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
95
|
version:
|
74
96
|
requirements: []
|
75
97
|
|
76
|
-
rubyforge_project:
|
98
|
+
rubyforge_project: lh-branch
|
77
99
|
rubygems_version: 1.2.0
|
78
100
|
signing_key:
|
79
101
|
specification_version: 3
|
80
102
|
summary: Easily manage branches based off lighthouse tickets.
|
81
103
|
test_files:
|
104
|
+
- test/command/test_base.rb
|
105
|
+
- test/commands/test_branch.rb
|
106
|
+
- test/commands/test_checkout.rb
|
107
|
+
- test/commands/test_commit.rb
|
108
|
+
- test/commands/test_delete.rb
|
109
|
+
- test/commands/test_merge.rb
|
110
|
+
- test/commands/test_pull.rb
|
111
|
+
- test/commands/test_push.rb
|
112
|
+
- test/commands/test_resolve.rb
|
113
|
+
- test/commands/test_update.rb
|
82
114
|
- test/test_helper.rb
|
83
|
-
- test/test_lighthouse_branch.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestLighthouseBranch < Test::Unit::TestCase
|
4
|
-
context "Tests" do
|
5
|
-
setup do
|
6
|
-
@lighthouse_branch = LighthouseBranch.new(
|
7
|
-
LIGHTHOUSE_ACCOUNT["account"],
|
8
|
-
LIGHTHOUSE_ACCOUNT["token"],
|
9
|
-
LIGHTHOUSE_ACCOUNT["project"])
|
10
|
-
|
11
|
-
@ticket_id = LIGHTHOUSE_ACCOUNT["ticket"]
|
12
|
-
end
|
13
|
-
|
14
|
-
should "initialize" do
|
15
|
-
assert_not_nil(@lighthouse_branch)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "return a ticket" do
|
19
|
-
assert_not_nil(@lighthouse_branch.ticket(@ticket_id))
|
20
|
-
assert_equal(Lighthouse::Ticket, @lighthouse_branch.ticket(@ticket_id).class)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "give a branch name for the ticket" do
|
24
|
-
assert_match(/#{LIGHTHOUSE_ACCOUNT["ticket"]}-[\w-]*/, @lighthouse_branch.branch_name(@ticket_id))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|