Permalink
Browse files

Add show and open commands

  • Loading branch information...
1 parent ebbd3ab commit f904af6fc3d4d3d75e79654cffd94e66bb57c939 @pcreux committed Oct 24, 2011
Showing with 58 additions and 0 deletions.
  1. +1 −0 Gemfile
  2. +4 −0 Gemfile.lock
  3. +35 −0 lib/gitmine.rb
  4. +18 −0 lib/gitmine/cli.rb
View
@@ -2,6 +2,7 @@ source "http://rubygems.org"
gem 'httparty', '>=0.6.1'
gem 'grit', '>=2.0.0'
+gem 'launchy', '>=2.0.0'
group :development do
gem 'rspec', '>=2.0.0'
View
@@ -1,13 +1,16 @@
GEM
remote: http://rubygems.org/
specs:
+ addressable (2.2.6)
crack (0.1.8)
diff-lcs (1.1.2)
grit (2.0.0)
diff-lcs (>= 1.1.2)
mime-types (>= 1.15)
httparty (0.6.1)
crack (= 0.1.8)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
mime-types (1.16)
rspec (2.5.0)
rspec-core (~> 2.5.0)
@@ -24,4 +27,5 @@ PLATFORMS
DEPENDENCIES
grit (>= 2.0.0)
httparty (>= 0.6.1)
+ launchy (>= 2.0.0)
rspec (>= 2.0.0)
View
@@ -3,6 +3,7 @@
require 'grit'
require 'yaml'
require 'httparty'
+require 'launchy'
class Gitmine
@@ -15,6 +16,27 @@ def self.list
end
end
+ def self.status
+ Gitmine.new.status
+ end
+
+ def status
+ if issue
+ puts "#{bold(issue.status)} - #{issue.subject} #{blue("(#{issue.assigned_to})")}"
+ end
+ end
+
+ def self.open
+ Gitmine.new.open
+ end
+
+ def open
+ issue_url = "#{Config.redmine_host}/issues/#{issue_id}"
+ if issue
+ Launchy.open issue_url
+ end
+ end
+
def initialize
@repo = Grit::Repo.new(ENV['PWD'])
@branch = File.read('./.git/HEAD').match(/^ref: refs\/heads\/(.+)/)[1]
@@ -26,6 +48,19 @@ def commits
end
end
+ def issue_id
+ @branch[/^\d+/]
+ end
+
+ # Return issue for current branch or nil
+ def issue
+ if issue_id
+ Issue.find(issue_id)
+ else
+ puts "No issue found for branch #{@branch}"
+ nil
+ end
+ end
# TODO specs
def self.branch(branch_name)
View
@@ -11,6 +11,10 @@ def self.run
delete
when "for_deploy", "reviewed"
reviewed
+ when "open"
+ open
+ when "status"
+ status
else
puts <<-EOS
Usage:
@@ -30,6 +34,12 @@ def self.run
Delete remote branch starting with ISSUE_ID
Example: gitmine delete 1234
+gitmine status
+ Show status of the current branch's issue
+
+gitmine open
+ Open current branch's issue in web browser
+
gitmine log
Displays latest 10 commits and the status of their associated Redmine tickets
EOS
@@ -55,4 +65,12 @@ def self.delete
def self.reviewed
Gitmine.reviewed(ARGV[1])
end
+
+ def self.open
+ Gitmine.open
+ end
+
+ def self.status
+ Gitmine.status
+ end
end

0 comments on commit f904af6

Please sign in to comment.