Class: Daun::RuggedDaun
- Inherits:
-
Object
- Object
- Daun::RuggedDaun
- Defined in:
- lib/daun/rugged_daun.rb
Overview
Implementation of daun using Rugged library.
Instance Method Summary collapse
-
#checkout ⇒ Object
Checkout git branches and tags in the git repository working directory.
-
#config ⇒ Object
Returns the git repository config as hash.
-
#init(remote_url) ⇒ Object
Bootstraps the git repository with the git remote repository URL and the default daun configurations.
-
#initialize(repository_path) ⇒ RuggedDaun
constructor
Creates a new RuggedDaun instance.
Constructor Details
#initialize(repository_path) ⇒ RuggedDaun
Creates a new RuggedDaun instance. An empty git repository will be initialized in the specified repository_path.
11 12 13 14 |
# File 'lib/daun/rugged_daun.rb', line 11 def initialize(repository_path) @repository = Rugged::Repository.init_at(repository_path) @logger = Logging.logger[self] end |
Instance Method Details
#checkout ⇒ Object
Checkout git branches and tags in the git repository working directory.
This method will fetch the latest update from git remote origin
configured
in the #init method.
Once the references are fetch, it will detect if there are new references,
updated references, and deleted references then act upon them
accordingly.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/daun/rugged_daun.rb', line 38 def checkout @logger.info 'Fetching git repository..' refs_diff = fetch_refs refs_diff.added(:remotes).each do |refs| @logger.info "Adding #{refs}.." checkout_remote_branch refs.to_local_branch, get_checkout_directory(refs) end refs_diff.updated(:remotes).each do |refs| @logger.info "Updating #{refs}.." checkout_remote_branch refs.to_local_branch, get_checkout_directory(refs) end refs_diff.deleted(:remotes).each do |refs| @logger.info "Deleting #{refs}.." FileUtils.rm_rf get_checkout_directory refs end refs_diff.added(:tags).each do |refs| @logger.info "Adding #{refs}.." checkout_tag refs.to_tag, get_checkout_directory(refs) end refs_diff.updated(:tags).each do |refs| @logger.info "Updating #{refs}.." checkout_tag(refs.to_tag, get_checkout_directory(refs), force: true) end refs_diff.deleted(:tags).each do |refs| @logger.info "Deleting #{refs}.." FileUtils.rm_rf get_checkout_directory refs end @logger.info "Finished checking out #{@repository.remotes['origin'].url} to #{@repository.workdir}" end |
#config ⇒ Object
Returns the git repository config as hash.
27 28 29 |
# File 'lib/daun/rugged_daun.rb', line 27 def config @repository.config end |
#init(remote_url) ⇒ Object
Bootstraps the git repository with the git remote repository URL and the default daun configurations.
19 20 21 22 23 24 |
# File 'lib/daun/rugged_daun.rb', line 19 def init(remote_url) @repository.remotes.create('origin', remote_url) @repository.config['daun.tag.blacklist'] = '' @repository.config['daun.tag.limit'] = '-1' @repository.config['daun.branch.blacklist'] = '' end |