Class: Octokom::Repository
- Includes:
- Shell
- Defined in:
- lib/octokom/repository.rb
Instance Method Summary collapse
-
#base_branch ⇒ Object
TODO Make base branch configurable.
- #head_branch ⇒ Object
-
#initialize(verbose) ⇒ Repository
constructor
A new instance of Repository.
- #last_commit_message ⇒ Object
- #pending_commits? ⇒ Boolean
- #push(branch) ⇒ Object
- #repo_path ⇒ Object
- #toplevel_path ⇒ Object
Methods included from Shell
Constructor Details
#initialize(verbose) ⇒ Repository
Returns a new instance of Repository.
5 6 7 |
# File 'lib/octokom/repository.rb', line 5 def initialize(verbose) @verbose = verbose end |
Instance Method Details
#base_branch ⇒ Object
TODO Make base branch configurable.
20 21 22 |
# File 'lib/octokom/repository.rb', line 20 def base_branch 'master' end |
#head_branch ⇒ Object
24 25 26 |
# File 'lib/octokom/repository.rb', line 24 def head_branch git('rev-parse --abbrev-ref HEAD') end |
#last_commit_message ⇒ Object
36 37 38 |
# File 'lib/octokom/repository.rb', line 36 def git('log -1 --oneline')[/^\w+\s(.*)$/, 1] end |
#pending_commits? ⇒ Boolean
28 29 30 31 32 33 34 |
# File 'lib/octokom/repository.rb', line 28 def pending_commits? current_sha1 = last_commits[/^\*\s((\w|-|_)*)\s+(\w{7})/, 3] remote_sha1 = last_commits[/remotes\/origin\/#{head_branch}\s+(\w{7})/, 1] return true if remote_sha1.blank? current_sha1 != remote_sha1 ? true : false end |
#push(branch) ⇒ Object
40 41 42 |
# File 'lib/octokom/repository.rb', line 40 def push(branch) git("push origin #{branch}") end |
#repo_path ⇒ Object
9 10 11 12 13 |
# File 'lib/octokom/repository.rb', line 9 def repo_path error('Git remote not defined') if remote_url.blank? path = remote_url.split('/')[-2..-1] path.join('/')[/(.*)\.git$/, 1] end |
#toplevel_path ⇒ Object
15 16 17 |
# File 'lib/octokom/repository.rb', line 15 def toplevel_path git('rev-parse --show-toplevel') end |