Class: Avm::Launcher::Git::Base

Inherits:
Paths::Real show all
Extended by:
ClassMethods
Includes:
DirtyFiles, Remotes, Subrepo, Underlying
Defined in:
lib/avm/launcher/git/base.rb,
lib/avm/launcher/git/base/remotes.rb,
lib/avm/launcher/git/base/subrepo.rb,
lib/avm/launcher/git/base/underlying.rb,
lib/avm/launcher/git/base/dirty_files.rb,
lib/avm/launcher/git/base/class_methods.rb

Defined Under Namespace

Modules: ClassMethods, DirtyFiles, Remotes, Subrepo, Underlying

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

by_root, find_root

Methods included from Underlying

#command, #execute, #execute!, #init, #system!

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

Methods inherited from Paths::Real

#basename, #dirname, #find_file_with_extension, #find_files_with_extension, #subpath

Constructor Details

#initialize(path) ⇒ Base

Returns a new instance of Base.



24
25
26
27
28
# File 'lib/avm/launcher/git/base.rb', line 24

def initialize(path)
  super(path)

  @eac_git = ::EacGit::Local.new(path)
end

Instance Attribute Details

#eac_gitObject (readonly)

Returns the value of attribute eac_git.



21
22
23
# File 'lib/avm/launcher/git/base.rb', line 21

def eac_git
  @eac_git
end

Instance Method Details

#current_branchObject



72
73
74
# File 'lib/avm/launcher/git/base.rb', line 72

def current_branch
  execute!(%w[symbolic-ref -q HEAD]).gsub(%r{\Arefs/heads/}, '').strip
end

#descendant?(descendant, ancestor) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
# File 'lib/avm/launcher/git/base.rb', line 41

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



66
67
68
69
70
# File 'lib/avm/launcher/git/base.rb', line 66

def fetch(remote_name, options = {})
  args = ['fetch', '-p', remote_name]
  args += %w[--tags --prune-tags --force] if options[:tags]
  execute!(*args)
end

#init_bareObject



30
31
32
33
34
# File 'lib/avm/launcher/git/base.rb', line 30

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



53
54
55
56
57
58
59
# File 'lib/avm/launcher/git/base.rb', line 53

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



61
62
63
64
# File 'lib/avm/launcher/git/base.rb', line 61

def push_all(remote_name)
  system!('push', '--all', remote_name)
  system!('push', '--tags', remote_name)
end

#raise(message) ⇒ Object



80
81
82
# File 'lib/avm/launcher/git/base.rb', line 80

def raise(message)
  ::Kernel.raise Avm::Launcher::Git::Error.new(self, message)
end

#reset_hard(ref) ⇒ Object



76
77
78
# File 'lib/avm/launcher/git/base.rb', line 76

def reset_hard(ref)
  execute!('reset', '--hard', ref)
end

#root_pathPathname

Returns:

  • (Pathname)


37
38
39
# File 'lib/avm/launcher/git/base.rb', line 37

def root_path
  @root_path ||= self.class.find_root(to_s)
end

#subtree_split(prefix) ⇒ Object



49
50
51
# File 'lib/avm/launcher/git/base.rb', line 49

def subtree_split(prefix)
  execute!('subtree', '-q', 'split', '-P', prefix).strip
end