Class: Geordi::Gitpt
- Inherits:
-
Object
- Object
- Geordi::Gitpt
- Defined in:
- lib/geordi/gitpt.rb
Instance Method Summary collapse
-
#initialize ⇒ Gitpt
constructor
A new instance of Gitpt.
- #run_branch(from_master: false) ⇒ Object
- #run_commit(git_args) ⇒ Object
Constructor Details
#initialize ⇒ Gitpt
12 13 14 15 16 |
# File 'lib/geordi/gitpt.rb', line 12 def initialize self.highline = HighLine.new self.settings = Settings.new self.client = build_client end |
Instance Method Details
#run_branch(from_master: false) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/geordi/gitpt.rb', line 29 def run_branch(from_master: false) story = choose_story || Interaction.fail('No story selected.') normalized_story_name = normalize_string(story.name) branch_list_string = if Util.testing? ENV['GEORDI_TESTING_GIT_BRANCHES'] || '' else `git branch --format="%(refname:short)"` end if branch_list_string.nil? || branch_list_string.strip.empty? Interaction.fail 'Could not determine local git branches.' end new_branch_name = "#{git_user_initials}/#{normalized_story_name}-#{story.id}" local_branches = branch_list_string.split("\n") branch_name = local_branches.find { |branch_name| branch_name == new_branch_name } branch_name ||= local_branches.find { |branch_name| branch_name.include? story.id.to_s } if branch_name.present? checkout_branch branch_name, new_branch: false else checkout_branch new_branch_name, new_branch: true, from_master: from_master end end |
#run_commit(git_args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/geordi/gitpt.rb', line 18 def run_commit(git_args) Interaction.warn " No staged changes. Will create an empty commit.\n WARNING\n\n story = choose_story\n if story\n create_commit \"[#\#{story.id}] \#{story.name}\", *git_args\n end\nend\n" unless Util.staged_changes? |