Browse files

added attachment action

  • Loading branch information...
1 parent bb3958a commit 5ee25b3056b91e27f43efc8730dfa744a9cce900 @schacon committed May 27, 2008
Showing with 28 additions and 40 deletions.
  1. +1 −0 lib/git-lighthouse/base.rb
  2. +19 −10 lib/git-lighthouse/cli.rb
  3. +0 −29 lighthouse.rake
  4. +8 −1 spec/cli_spec.rb
View
1 lib/git-lighthouse/base.rb
@@ -1,6 +1,7 @@
module GitLighthouse
class Base
+ attr_reader :lh_url, :account, :projectId, :token, :email, :password
def initialize(working_dir, options = {})
@git = Git.init(working_dir, options)
View
29 lib/git-lighthouse/cli.rb
@@ -31,10 +31,12 @@ def execute!
handle_ticket_show
when 'checkout', 'co'
handle_ticket_checkout
- when 'comment'
- handle_ticket_comment
when 'apply'
handle_ticket_apply
+ when 'attachment'
+ handle_ticket_attachment
+ when 'comment'
+ handle_ticket_comment
when 'recent'
handle_ticket_recent
else
@@ -135,16 +137,17 @@ def handle_ticket_show
# outputs actual patch file, include ID=XX
# (and optionally NUMBER=XX if more than 1)
- def show_attach
- setup_env
+ def handle_ticket_attachment
+ tid = ARGV[1].chomp
+ attId = ARGV[1].chomp
- if tic = get_ticket(ENV['ID'])
- doc = Hpricot(open(get_url(tic)))
+ if tic = @lh.get_ticket(tid)
+ doc = Hpricot(open(@lh.get_url(tic)))
urls = []
(doc/"ul.attachments"/:li/:ins/:h4/:a).each do |t|
- urls << LH_URL + t['href']
+ urls << @lh.lh_url + t['href']
end
- idx = ((urls.size > 1) && (ENV['NUMBER'])) ? ENV['NUMBER'].to_i - 1 : 0
+ idx = ((urls.size > 1) && (attId)) ? attId.to_i - 1 : 0
puts open(urls[idx]).read if urls[idx]
end
end
@@ -239,8 +242,14 @@ def get_editor_message(message_file = nil)
def parse_options! #:nodoc:
if args.empty?
- warn "Please specify at least one action to execute."
- puts " list state show new checkout comment tag assign "
+ warn "Please specify at least one action to execute:"
+ puts " list - list patch tickets in lighthouse"
+ puts " show (id) - show ticket detail "
+ puts " attachment (ticket_id) [attachment number] - output patch to stdout"
+ #puts " checkout (id) - create a new branch and apply ticket to it"
+ #puts " apply (id) - apply ticket to current branch"
+ #puts " push (id) - create new patch file and push to ticket"
+ #puts " comment (id) - add comment to ticket"
exit
end
View
29 lighthouse.rake
@@ -1,29 +0,0 @@
-# * rake patch:setup # setup your token, TOKEN=XXXX..
-#
-# * rake patch:list # list all open patch tickets
-#
-# * rake patch:show:ticket # show patch ticket, include ID=XX
-# * rake patch:show:attach # outputs actual patch file, include ID=XX (and o...
-# * rake patch:show:comments # lists all comments on a ticket and adds up the +1s
-#
-# * rake patch:comment # review a patch - comment and optionally +1 it (ID=XX)
-#
-# I would add a task to upload new attachments, but as far as I can tell, Lighthouse API
-# has no way to do that. I'll try to figure that out next, probably.
-
-
-
-namespace :patch do
-
- desc 'review a patch - comment and optionally +1 it'
- task :comment => 'patch:requires' do
-
- end
-
- # possible future stuff :
- # desc 'create a new branch and apply ticket patch (run tests?)'
- # desc 'diff patched branch'
- # desc 'rebase patched branch'
- # desc 'create a new ticket with a patch'
-
-end
View
9 spec/cli_spec.rb
@@ -49,12 +49,19 @@
ob[0].should match(/this is a super cool ticket/)
end
end
+
+ it "should be able to output a patch file to stdout" do
+ ARGV = ['attachment', '1']
+ ob = output_buffer do
+ GitLighthouse::CLI.execute
+ end
+ ob[0].should match(/Subject: [PATCH] test patch/)
+ end
it "should show a help message"
it "should determine the difference between a format-patch and a diff patch"
- it "should be able to output a patch file to stdout"
it "should apply a patch file as a new branch"

0 comments on commit 5ee25b3

Please sign in to comment.