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',
},
commit: 'false'
}
GitRepoUpgrader.upgrade
Constant Summary collapse
- TMP_DIR_PREFIX =
'GitRepoUpgrader_'
- PROJECT_DIR =
Dir.pwd
- GIT_REPO_NAME_REGEX =
/\/([^\/]+).git/
- VERSION =
'0.0.7'.freeze
Class Method Summary collapse
Class Method Details
.upgrade(options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/git_repo_upgrader.rb', line 45 def self.upgrade() puts '*****************************'.yellow puts "** Git Repo Upgrader #{GitRepoUpgrader::VERSION}".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] if [:commit] != false && [:commit] != 'false' && [:commit] != 'skip' _commit_files [:files_to_copy], repo_name, type: [:commit] end puts puts "Everything done, be happy! :-) ".magenta end |