Class: Mj::Git::RemoteBranch
- Inherits:
-
Object
- Object
- Mj::Git::RemoteBranch
- Defined in:
- lib/mj/git/remote_branch.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #checkout_command ⇒ Object
- #delete ⇒ Object
- #has_pr? ⇒ Boolean
-
#initialize(name, command_executer: CommandExecuter.new) ⇒ RemoteBranch
constructor
A new instance of RemoteBranch.
- #last_commit_date ⇒ Object
- #length ⇒ Object
- #pr ⇒ Git::PullRequest
- #to_local ⇒ Object
Constructor Details
#initialize(name, command_executer: CommandExecuter.new) ⇒ RemoteBranch
Returns a new instance of RemoteBranch.
8 9 10 11 |
# File 'lib/mj/git/remote_branch.rb', line 8 def initialize(name, command_executer: CommandExecuter.new) @name = name @command_executer = command_executer end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/mj/git/remote_branch.rb', line 6 def name @name end |
Instance Method Details
#checkout_command ⇒ Object
13 14 15 |
# File 'lib/mj/git/remote_branch.rb', line 13 def checkout_command "git checkout -b #{local_branch_name} #{name}" end |
#delete ⇒ Object
42 43 44 |
# File 'lib/mj/git/remote_branch.rb', line 42 def delete @command_executer.execute("git push origin :#{local_branch_name}") end |
#has_pr? ⇒ Boolean
29 30 31 |
# File 'lib/mj/git/remote_branch.rb', line 29 def has_pr? !pr.nil? end |
#last_commit_date ⇒ Object
17 18 19 |
# File 'lib/mj/git/remote_branch.rb', line 17 def last_commit_date @last_commit_date ||= DateTime.parse(@command_executer.execute("git log -1 --format=%cd #{name}").first) end |
#length ⇒ Object
21 22 23 |
# File 'lib/mj/git/remote_branch.rb', line 21 def length @name.length end |
#pr ⇒ Git::PullRequest
34 35 36 37 38 39 40 |
# File 'lib/mj/git/remote_branch.rb', line 34 def pr if defined?(@pr) return @pr end @pr ||= fetch_pr end |
#to_local ⇒ Object
25 26 27 |
# File 'lib/mj/git/remote_branch.rb', line 25 def to_local LocalBranch.new(local_branch_name) end |