Permalink
Browse files

added comment viewing for a ticket

  • Loading branch information...
1 parent 5ee25b3 commit 49b9d740e2300d8bdfba5674d5418840b6807099 @schacon committed May 27, 2008
Showing with 53 additions and 41 deletions.
  1. +1 −0 .gitignore
  2. +13 −19 Manifest.txt
  3. 0 PostInstall.txt
  4. +16 −0 lib/git-lighthouse/base.rb
  5. +23 −22 lib/git-lighthouse/cli.rb
View
@@ -0,0 +1 @@
+pkg/*
View
@@ -1,25 +1,19 @@
+bin/git-lh
+config/hoe.rb
+config/requirements.rb
History.txt
+lib/git-lighthouse
+lib/git-lighthouse/base.rb
+lib/git-lighthouse/cli.rb
+lib/git-lighthouse/lighthouse.rb
+lib/git-lighthouse/version.rb
+lib/git-lighthouse.rb
License.txt
Manifest.txt
PostInstall.txt
-README.txt
Rakefile
-config/hoe.rb
-config/requirements.rb
-lib/git-lh.rb
-lib/git-lh/version.rb
-script/console
-script/destroy
-script/generate
-script/txt2html
+README.txt
setup.rb
-tasks/deployment.rake
-tasks/environment.rake
-tasks/website.rake
-test/test_git-lh.rb
-test/test_helper.rb
-website/index.html
-website/index.txt
-website/javascripts/rounded_corners_lite.inc.js
-website/stylesheets/screen.css
-website/template.html.erb
+spec/cli_spec.rb
+spec/spec_helper.rb
+TODO.txt
View
No changes.
View
@@ -19,6 +19,7 @@ def initialize(working_dir, options = {})
Lighthouse.password = @password if @password
end
+
def get_project
Lighthouse::Project.find(@projectId)
end
@@ -48,5 +49,20 @@ def get_ticket(ticket_id)
return false
end
+
+ def get_attachment_data(tid, attId)
+ output = ''
+ if tic = get_ticket(tid)
+ doc = Hpricot(open(get_url(tic)))
+ urls = []
+ (doc/"ul.attachments"/:li/:ins/:h4/:a).each do |t|
+ urls << @lh_url + t['href']
+ end
+ idx = ((urls.size > 1) && (attId)) ? attId.to_i - 1 : 0
+ output = open(urls[idx]).read if urls[idx]
+ end
+ output
+ end
+
end
end
View
@@ -29,12 +29,14 @@ def execute!
handle_ticket_list
when 'show'
handle_ticket_show
+ when 'comments'
+ handle_ticket_comments
when 'checkout', 'co'
handle_ticket_checkout
- when 'apply'
- handle_ticket_apply
when 'attachment'
handle_ticket_attachment
+ when 'apply'
+ handle_ticket_apply
when 'comment'
handle_ticket_comment
when 'recent'
@@ -65,8 +67,8 @@ def handle_ticket_comment
end
def handle_ticket_checkout
- #tid = ARGV[1].chomp
- #tic.ticket_checkout(tid)
+ tid = ARGV[1].chomp
+ @lh.ticket_checkout(tid)
end
## LIST TICKETS ##
@@ -135,35 +137,33 @@ def handle_ticket_show
end
end
+ # outputs actual patch file
+ def handle_ticket_attachment
+ tid = ARGV[1].chomp
+ attId = ARGV[2].chomp
+ puts @lh.get_attachment_data(tid, attId)
+ end
+
# outputs actual patch file, include ID=XX
# (and optionally NUMBER=XX if more than 1)
def handle_ticket_attachment
tid = ARGV[1].chomp
- attId = ARGV[1].chomp
-
- 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.lh_url + t['href']
- end
- idx = ((urls.size > 1) && (attId)) ? attId.to_i - 1 : 0
- puts open(urls[idx]).read if urls[idx]
- end
+ attId = ARGV[2].chomp
+ puts @lh.get_attachment_data(tid, attId)
end
-
- def show_comments
- setup_env
-
- if tic = get_ticket(ENV['ID'])
+ def handle_ticket_comments
+ tid = ARGV[1].chomp
+ if tic = @lh.get_ticket(tid)
+ tic_url = @lh.get_url(tic)
puts
puts 'Title : ' + tic.title
+ puts 'URL : ' + tic_url
puts
puts '-- Comments --'
puts
- doc = Hpricot(open(get_xml_url(ENV['ID'])))
+ doc = Hpricot(open(@lh.get_xml_url(tid)))
(doc/"versions > version").each do |comment|
#puts (comment/'updated-at').first.inner_html rescue nil
puts word_wrap((comment/:body).inner_html) rescue nil
@@ -245,8 +245,9 @@ def parse_options! #:nodoc:
warn "Please specify at least one action to execute:"
puts " list - list patch tickets in lighthouse"
puts " show (id) - show ticket detail "
+ puts " comments (id) - shows all comments on this ticket"
puts " attachment (ticket_id) [attachment number] - output patch to stdout"
- #puts " checkout (id) - create a new branch and apply ticket to it"
+ 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"

0 comments on commit 49b9d74

Please sign in to comment.