Class: EacLauncher::Git::Base

Inherits:
Paths::Real show all
Extended by:
ClassMethods
Includes:
DirtyFiles, Remotes, Subrepo, Underlying
Defined in:
lib/eac_launcher/git/base.rb,
lib/eac_launcher/git/base/remotes.rb,
lib/eac_launcher/git/base/subrepo.rb,
lib/eac_launcher/git/base/underlying.rb,
lib/eac_launcher/git/base/dirty_files.rb,
lib/eac_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.



23
24
25
26
27
# File 'lib/eac_launcher/git/base.rb', line 23

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.



20
21
22
# File 'lib/eac_launcher/git/base.rb', line 20

def eac_git
  @eac_git
end

Instance Method Details

#current_branchObject



71
72
73
# File 'lib/eac_launcher/git/base.rb', line 71

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

#descendant?(descendant, ancestor) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
# File 'lib/eac_launcher/git/base.rb', line 40

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



65
66
67
68
69
# File 'lib/eac_launcher/git/base.rb', line 65

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

#init_bareObject



29
30
31
32
33
# File 'lib/eac_launcher/git/base.rb', line 29

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



52
53
54
55
56
57
58
# File 'lib/eac_launcher/git/base.rb', line 52

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



60
61
62
63
# File 'lib/eac_launcher/git/base.rb', line 60

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

#raise(message) ⇒ Object



79
80
81
# File 'lib/eac_launcher/git/base.rb', line 79

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

#reset_hard(ref) ⇒ Object



75
76
77
# File 'lib/eac_launcher/git/base.rb', line 75

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

#root_pathPathname

Returns:

  • (Pathname)


36
37
38
# File 'lib/eac_launcher/git/base.rb', line 36

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

#subtree_split(prefix) ⇒ Object



48
49
50
# File 'lib/eac_launcher/git/base.rb', line 48

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