Class: Avm::Git::Launcher::Base
- Inherits:
-
Launcher::Paths::Real
- Object
- Launcher::Paths::Real
- Avm::Git::Launcher::Base
show all
- Extended by:
- ClassMethods
- Includes:
- DirtyFiles, Remotes, Subrepo, Underlying
- Defined in:
- lib/avm/git/launcher/base.rb,
lib/avm/git/launcher/base/remotes.rb,
lib/avm/git/launcher/base/subrepo.rb,
lib/avm/git/launcher/base/underlying.rb,
lib/avm/git/launcher/base/dirty_files.rb,
lib/avm/git/launcher/base/class_methods.rb
Defined Under Namespace
Modules: ClassMethods, DirtyFiles, Remotes, Subrepo, Underlying
Instance Attribute Summary collapse
Instance Method Summary
collapse
by_root, find_root
Methods included from Underlying
#command, #init
Methods included from Subrepo
#subrepo_remote_url, #subrepo_status
Methods included from Remotes
#assert_remote_url, #remote, #remote_branch_sha, #remote_exist?, #remote_hashs
Methods included from DirtyFiles
#dirty_files
Constructor Details
#initialize(path) ⇒ Base
Returns a new instance of Base.
25
26
27
28
29
|
# File 'lib/avm/git/launcher/base.rb', line 25
def initialize(path)
super
@eac_git = ::EacGit::Local.new(path)
end
|
Instance Attribute Details
#eac_git ⇒ Object
Returns the value of attribute eac_git.
21
22
23
|
# File 'lib/avm/git/launcher/base.rb', line 21
def eac_git
@eac_git
end
|
Instance Method Details
#current_branch ⇒ Object
73
74
75
|
# File 'lib/avm/git/launcher/base.rb', line 73
def current_branch
execute!(%w[symbolic-ref -q HEAD]).gsub(%r{\Arefs/heads/}, '').strip
end
|
#descendant?(descendant, ancestor) ⇒ Boolean
42
43
44
45
46
47
48
|
# File 'lib/avm/git/launcher/base.rb', line 42
def descendant?(descendant, ancestor)
base = merge_base(descendant, ancestor)
return false if base.blank?
revparse = execute!('rev-parse', '--verify', ancestor).strip
base == revparse
end
|
#fetch(remote_name, options = {}) ⇒ Object
67
68
69
70
71
|
# File 'lib/avm/git/launcher/base.rb', line 67
def fetch(remote_name, options = {})
args = ['fetch', '-p', remote_name]
args += %w[--tags --prune-tags --force] if options[:tags]
execute!(*args)
end
|
#init_bare ⇒ Object
31
32
33
34
35
|
# File 'lib/avm/git/launcher/base.rb', line 31
def init_bare
FileUtils.mkdir_p(self)
::EacRubyUtils::Envs.local.command('git', 'init', '--bare', self).execute! unless
File.exist?(subpath('.git'))
end
|
#push(remote_name, refspecs, options = {}) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/avm/git/launcher/base.rb', line 54
def push(remote_name, refspecs, options = {})
refspecs = [refspecs] unless refspecs.is_a?(Array)
args = ['push']
args << '--dry-run' if options[:dryrun]
args << '--force' if options[:force]
system!(args + [remote_name] + refspecs)
end
|
#push_all(remote_name) ⇒ Object
62
63
64
65
|
# File 'lib/avm/git/launcher/base.rb', line 62
def push_all(remote_name)
system!('push', '--all', remote_name)
system!('push', '--tags', remote_name)
end
|
#raise(message) ⇒ Object
81
82
83
|
# File 'lib/avm/git/launcher/base.rb', line 81
def raise(message)
::Kernel.raise Avm::Git::Launcher::Error.new(self, message)
end
|
#reset_hard(ref) ⇒ Object
77
78
79
|
# File 'lib/avm/git/launcher/base.rb', line 77
def reset_hard(ref)
execute!('reset', '--hard', ref)
end
|
#root_path ⇒ Pathname
38
39
40
|
# File 'lib/avm/git/launcher/base.rb', line 38
def root_path
@root_path ||= self.class.find_root(to_s)
end
|
#subtree_split(prefix) ⇒ Object
50
51
52
|
# File 'lib/avm/git/launcher/base.rb', line 50
def subtree_split(prefix)
execute!('subtree', '-q', 'split', '-P', prefix).strip
end
|