Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent branch tracking #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/commands/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions lib/commands/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/commands/pick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down