Class: GitPrettyAccept::Transaction
- Inherits:
-
Object
- Object
- GitPrettyAccept::Transaction
- Includes:
- Methadone::CLILogging
- Defined in:
- lib/git_pretty_accept/transaction.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#let_user_edit_message ⇒ Object
readonly
Returns the value of attribute let_user_edit_message.
Instance Method Summary collapse
- #call ⇒ Object
- #commands ⇒ Object
-
#initialize(branch, let_user_edit_message = true) ⇒ Transaction
constructor
A new instance of Transaction.
- #source_branch ⇒ Object
Constructor Details
#initialize(branch, let_user_edit_message = true) ⇒ Transaction
7 8 9 10 |
# File 'lib/git_pretty_accept/transaction.rb', line 7 def initialize(branch, = true) @branch = branch = end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
5 6 7 |
# File 'lib/git_pretty_accept/transaction.rb', line 5 def branch @branch end |
#let_user_edit_message ⇒ Object (readonly)
Returns the value of attribute let_user_edit_message.
5 6 7 |
# File 'lib/git_pretty_accept/transaction.rb', line 5 def end |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/git_pretty_accept/transaction.rb', line 27 def call commands.each_with_index do |command, i| info "\n#{command}" unless system(command) error "\nDue to the error above, " + "the following commands were not executed: " + commands[i + 1, commands.size].join("\n") exit! end end end |
#commands ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/git_pretty_accept/transaction.rb', line 12 def commands [ "git fetch origin", "git rebase origin/#{source_branch}", "git checkout #{branch}", "git rebase origin/#{source_branch}", "git push --force origin #{branch}", "git checkout #{source_branch}", MergeCommand.new(branch, ).to_s, "git push origin #{source_branch}", "git branch -d #{branch}", "git push origin :#{branch}" ] end |
#source_branch ⇒ Object
39 40 41 42 43 |
# File 'lib/git_pretty_accept/transaction.rb', line 39 def source_branch return @source_branch if @source_branch our = Git.open('.') @source_branch = our.branches.find(&:current).to_s end |