diff --git a/lib/commands/base.rb b/lib/commands/base.rb index 9d9ee5f..00e48e1 100644 --- a/lib/commands/base.rb +++ b/lib/commands/base.rb @@ -63,15 +63,21 @@ def parse_gitconfig id = get("git config --get pivotal.project-id").strip name = get("git config --get pivotal.full-name").strip integration_branch = get("git config --get pivotal.integration-branch").strip + parent_branch = get("git config --get pivotal.parent-branch").strip # git config --global pivotal.parent-branch origin/master only_mine = get("git config --get pivotal.only-mine").strip append_name = get("git config --get pivotal.append-name").strip use_ssl = get("git config --get pivotal.use-ssl").strip + upcoming = get("git config --get --int pivotal.upcoming").strip + upcoming_with_desc = get("git config --get --int pivotal.upcoming-with-desc").strip options[:api_token] = token unless token == "" options[:project_id] = id unless id == "" options[:full_name] = name unless name == "" options[:integration_branch] = integration_branch unless integration_branch == "" + options[:parent_branch] = parent_branch unless parent_branch == "" options[:only_mine] = (only_mine != "") unless name == "" + options[:upcoming] = upcoming.to_i unless upcoming == "" + options[:upcoming_with_desc] = upcoming_with_desc.to_i unless upcoming_with_desc == "" options[:append_name] = (append_name != "") options[:use_ssl] = (/^true$/i.match(use_ssl)) end @@ -89,6 +95,9 @@ def parse_argv(*args) opts.on("-D", "--defaults", "Accept default options. No-interaction mode") { |d| options[:defaults] = d } opts.on("-q", "--quiet", "Quiet, no-interaction mode") { |q| options[:quiet] = q } opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| options[:verbose] = v } + opts.banner = "Usage: git info [options]" + opts.on("-u", "--upcoming-stories=", "Show upcoming stories (number of the stories to be shown) for instance -u10") { |u| options[:upcoming] = u.to_i } + opts.on("-d", "--upcoming-stories-with-description=", "Show upcoming stories (number of the stories to be shown) with description") { |d| options[:upcoming_with_desc] = d.to_i } opts.on_tail("-h", "--help", "This usage guide") { put opts.to_s; exit 0 } end.parse!(args) end diff --git a/lib/commands/info.rb b/lib/commands/info.rb index a33be75..10535de 100644 --- a/lib/commands/info.rb +++ b/lib/commands/info.rb @@ -15,6 +15,20 @@ def run! put "URL: #{story.url}" put "Description: #{story.description}" + fetched_stories = stories + + if fetched_stories.size > 0 + puts + put "Upcoming stories:" + + fetched_stories.each do |s| + put " #{s.story_type[0].upcase!}#{rounded_text s.estimate}: #{s.name}" + put " #{s.url}\tby #{s.requested_by}\t#{rounded_text s.labels}" + puts "\t\t#{s.description}" if s.description != '' && options[:upcoming_with_desc] + puts + end + end + return 0 end @@ -27,5 +41,18 @@ def story_id def story @story ||= project.stories.find(story_id) end + + def stories + limit = options[:upcoming] || options[:upcoming_with_desc] || 0 + return [] if limit == 0 + conditions = {:current_state => "unstarted", :limit => limit, :offset => 0} + conditions[:owned_by] = options[:full_name] if options[:only_mine] + @story = project.stories.all(conditions) + end + + def rounded_text(text) + '(' + text.to_s + ')' if text + end + end end diff --git a/lib/commands/pick.rb b/lib/commands/pick.rb index 769be49..0259512 100755 --- a/lib/commands/pick.rb +++ b/lib/commands/pick.rb @@ -50,8 +50,8 @@ def run! branch = "#{story.id}-#{suffix_or_prefix}" end if get("git branch").match(branch).nil? + sys "git checkout -b #{branch} #{options[:parent_branch]}" put "Switched to a new branch '#{branch}'" - sys "git checkout -b #{branch}" end return 0