Class: ConfCtl::GitRepoMirror
- Inherits:
-
Object
- Object
- ConfCtl::GitRepoMirror
- Defined in:
- lib/confctl/git_repo_mirror.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #diff(from_ref, to_ref, opts: []) ⇒ Object
-
#initialize(url, quiet: false) ⇒ GitRepoMirror
constructor
A new instance of GitRepoMirror.
- #log(from_ref, to_ref, opts: []) ⇒ Object
- #revision_parse(str) ⇒ Object
- #setup(ref: nil) ⇒ Object
Constructor Details
#initialize(url, quiet: false) ⇒ GitRepoMirror
Returns a new instance of GitRepoMirror.
10 11 12 13 14 15 |
# File 'lib/confctl/git_repo_mirror.rb', line 10 def initialize(url, quiet: false) @url = url @quiet = quiet @name = Digest::SHA256.hexdigest(url) @cmd = SystemCommand.new end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/confctl/git_repo_mirror.rb', line 6 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/confctl/git_repo_mirror.rb', line 6 def url @url end |
Instance Method Details
#diff(from_ref, to_ref, opts: []) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/confctl/git_repo_mirror.rb', line 44 def diff(from_ref, to_ref, opts: []) ret = "git diff for #{from_ref}..#{to_ref}\n" ret << git_repo( 'diff', opts:, args: ["#{from_ref}..#{to_ref}"] ) ret end |
#log(from_ref, to_ref, opts: []) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/confctl/git_repo_mirror.rb', line 32 def log(from_ref, to_ref, opts: []) ret = "git log for #{from_ref}..#{to_ref}\n" ret << git_repo( 'log', opts: ['--no-decorate', '--left-right', '--cherry-mark'] + opts, args: ["#{from_ref}..#{to_ref}"] ) ret end |
#revision_parse(str) ⇒ Object
26 27 28 |
# File 'lib/confctl/git_repo_mirror.rb', line 26 def revision_parse(str) git_repo('rev-parse', args: [str]) end |
#setup(ref: nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/confctl/git_repo_mirror.rb', line 17 def setup(ref: nil) File.stat(mirror_path) rescue Errno::ENOENT FileUtils.mkdir_p(mirror_path) git('clone', args: ['--mirror', url, mirror_path]) else git_repo('fetch', opts: ['--no-show-forced-updates'], args: (ref ? ['origin', ref] : [])) end |