Class: Flux::Git::Branch
- Inherits:
-
Struct
- Object
- Struct
- Flux::Git::Branch
- Defined in:
- lib/flux/git.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#remote ⇒ Object
Returns the value of attribute remote.
-
#repo_path ⇒ Object
Returns the value of attribute repo_path.
Class Method Summary collapse
- .current(repo_path = Git.repo_path) ⇒ Object
- .local(name, repo_path = Git.repo_path) ⇒ Object
- .remote(name, remote = 'origin', repo_path = Git.repo_path) ⇒ Object
Instance Method Summary collapse
- #checkout ⇒ Object
- #config(var, value = nil) ⇒ Object
- #create(parent) ⇒ Object
- #fqdn ⇒ Object
- #include?(branch) ⇒ Boolean (also: #includes?)
-
#initialize(repo_path, remote, name) ⇒ Branch
constructor
A new instance of Branch.
- #publish(upstream) ⇒ Object
- #synced? ⇒ Boolean
- #top ⇒ Object
- #track(upstream) ⇒ Object
- #upstream ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
37 38 39 |
# File 'lib/flux/git.rb', line 37 def name @name end |
#remote ⇒ Object
Returns the value of attribute remote
37 38 39 |
# File 'lib/flux/git.rb', line 37 def remote @remote end |
#repo_path ⇒ Object
Returns the value of attribute repo_path
37 38 39 |
# File 'lib/flux/git.rb', line 37 def repo_path @repo_path end |
Class Method Details
.current(repo_path = Git.repo_path) ⇒ Object
38 39 40 |
# File 'lib/flux/git.rb', line 38 def self.current(repo_path = Git.repo_path) Branch.local(Git.repo(repo_path).head.name, repo_path) end |
Instance Method Details
#checkout ⇒ Object
71 72 73 |
# File 'lib/flux/git.rb', line 71 def checkout tap { @git.checkout({}, @name) } end |
#config(var, value = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/flux/git.rb', line 57 def config(var, value = nil) gitvar = "branch.#{name}.#{var.gsub('_', '')}" if value @git.config({:add => true}, gitvar, value) else @git.config({}, gitvar).chomp end end |
#create(parent) ⇒ Object
67 68 69 |
# File 'lib/flux/git.rb', line 67 def create(parent) tap { @git.branch({}, @name, parent.name) } end |
#fqdn ⇒ Object
75 76 77 |
# File 'lib/flux/git.rb', line 75 def fqdn remote ? "#{remote}/#{name}" : name end |
#include?(branch) ⇒ Boolean Also known as: includes?
79 80 81 |
# File 'lib/flux/git.rb', line 79 def include?(branch) @repo.commits_between(fqdn, branch.fqdn).empty? end |
#publish(upstream) ⇒ Object
89 90 91 92 93 |
# File 'lib/flux/git.rb', line 89 def publish(upstream) tap { @git.push({}, upstream.remote, "+#{@name}:#{upstream.name}") } end |
#synced? ⇒ Boolean
99 100 101 |
# File 'lib/flux/git.rb', line 99 def synced? upstream.top.sha == top.sha end |
#top ⇒ Object
85 86 87 |
# File 'lib/flux/git.rb', line 85 def top @repo.commits(fqdn, 1).first end |
#track(upstream) ⇒ Object
95 96 97 |
# File 'lib/flux/git.rb', line 95 def track(upstream) tap { @git.branch({:set_upstream => true}, @name, upstream.fqdn) } end |