Module: GitRepoUpgrader
- Defined in:
- lib/git_repo_upgrader.rb,
lib/git_repo_upgrader/version.rb
Overview
GitRepoUpgrader
Checkout a git repository to a temporary directory and extract specific files from there into your project
Example:
= {
repo: {
uri: 'https://github.com/username/project.git',
branch: 'develop',
},
files_to_copy: {
'dist/app.bundle.js' => 'web/js/lib/project/app.bundle.js',
'dist/app.bundle.css' => 'web/js/lib/project/app.bundle.css',
# copy a whole directory recursively
'dist/img' => 'web/js/lib/project/img',
}
}
GitRepoUpgrader.upgrade
Constant Summary collapse
- TMP_DIR_PREFIX =
'GitRepoUpgrader_'
- PROJECT_DIR =
Dir.pwd
- GIT_REPO_NAME_REGEX =
/\/([^\/]+).git/
- VERSION =
'0.0.5'.freeze
Class Method Summary collapse
Class Method Details
.upgrade(options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/git_repo_upgrader.rb', line 39 def self.upgrade() puts '*****************************'.yellow puts '** Git Repo Upgrader'.yellow puts '*****************************'.yellow repo_dir, tmp_dir = _checkout_git_repo [:repo][:uri], [:repo][:branch] _copy_files_from_checkout repo_dir, [:files_to_copy] _cleanup_checkout tmp_dir repo_name = [:repo][:uri].match(GIT_REPO_NAME_REGEX)[1] _commit_files [:files_to_copy], repo_name puts puts "Everything done, be happy! :-) ".magenta end |