Module: FerretsOnFire::DSL::GitDSL

Included in:
FerretsOnFire::DSL
Defined in:
lib/ferrets_on_fire/dsl/git_dsl.rb

Instance Method Summary collapse

Instance Method Details

#clone_git_repo(remote, target: '', checkout: nil, skip_setup: false) ⇒ Object



20
21
22
23
24
# File 'lib/ferrets_on_fire/dsl/git_dsl.rb', line 20

public def clone_git_repo(remote, target: '', checkout: nil, skip_setup: false)
  run "git clone #{remote} #{target}", as: 'clone git repo'
  run "git checkout #{checkout}", as: "checkout #{checkout}", dir: target unless checkout.nil?
  run('bin/setup', dir: target, as: 'bin/setup', bundler: true) if !skip_setup && File.exists?('bin/setup')
end

#find_git_tags(dir) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/ferrets_on_fire/dsl/git_dsl.rb', line 37

public def find_git_tags(dir)
  repo = _git_setup(dir)

  # Find all tags
  tags = []
  repo.references.each('refs/tags/*') { |ref| tags << ref }
  tags
end

#get_git_master_ref(dir) ⇒ Object



46
47
48
49
# File 'lib/ferrets_on_fire/dsl/git_dsl.rb', line 46

public def get_git_master_ref(dir)
  repo = _git_setup(dir)
  repo.ref('refs/remotes/origin/master')
end

#git_checkout(dir, checkout) ⇒ Object



32
33
34
35
# File 'lib/ferrets_on_fire/dsl/git_dsl.rb', line 32

public def git_checkout(dir, checkout)
  repo = _git_setup(dir)
  repo.checkout checkout, strategy: :force
end

#update_git_repo(path: nil, desired_branch: nil, skip_update: false) ⇒ Object

Updates the git repository in the current directory and runs bin/update

Parameters:

  • path (String) (defaults to: nil)

    The directory to use, default is the current one



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ferrets_on_fire/dsl/git_dsl.rb', line 4

public def update_git_repo(path: nil, desired_branch: nil, skip_update: false)
  run 'git pull -r --autostash', dir: path, as: 'git pull'

  # get current branch name
  if desired_branch
    current_branch = run('git branch | grep \*', dir: path, quiet: true).sub('*', '').strip

    unless current_branch == desired_branch
      warn "WARNING: Current branch is not #{desired_branch} (it's #{current_branch})"
    end
  end

  run('bin/update', dir: path, as: 'bin/update', bundler: true) if !skip_update && File.exists?('bin/update')
end