Class: R10K::Git::ShellGit::BareRepository

Inherits:
BaseRepository show all
Defined in:
lib/r10k/git/shellgit/bare_repository.rb

Overview

Create and manage Git bare repositories.

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Method Summary collapse

Methods inherited from BaseRepository

#branches, #is_branch?, #is_tag?, #ref_type, #remotes, #resolve, #tags

Methods included from Logging

debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Constructor Details

#initialize(basedir, dirname) ⇒ BareRepository

Returns a new instance of BareRepository.

Parameters:

  • basedir (String)

    The base directory of the Git repository

  • dirname (String)

    The directory name of the Git repository



9
10
11
# File 'lib/r10k/git/shellgit/bare_repository.rb', line 9

def initialize(basedir, dirname)
  @path = Pathname.new(File.join(basedir, dirname))
end

Instance Method Details

#clone(remote) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/r10k/git/shellgit/bare_repository.rb', line 23

def clone(remote)
  proxy = R10K::Git.get_proxy_for_remote(remote)

  R10K::Git.with_proxy(proxy) do
    git ['clone', '--mirror', remote, git_dir.to_s]
  end
end

#exist?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/r10k/git/shellgit/bare_repository.rb', line 40

def exist?
  @path.exist?
end

#fetch(remote_name = 'origin') ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/r10k/git/shellgit/bare_repository.rb', line 31

def fetch(remote_name='origin')
  remote = remotes[remote_name]
  proxy = R10K::Git.get_proxy_for_remote(remote)

  R10K::Git.with_proxy(proxy) do
    git ['fetch', remote_name, '--prune'], :git_dir => git_dir.to_s
  end
end

#git_dirPathname

Returns The path to this Git repository.

Returns:

  • (Pathname)

    The path to this Git repository



14
15
16
# File 'lib/r10k/git/shellgit/bare_repository.rb', line 14

def git_dir
  @path
end

#objects_dirPathname

Returns The path to the objects directory in this Git repository.

Returns:

  • (Pathname)

    The path to the objects directory in this Git repository



19
20
21
# File 'lib/r10k/git/shellgit/bare_repository.rb', line 19

def objects_dir
  @path + "objects"
end