Class: GemBootstrap::GitUtils
- Inherits:
-
Object
- Object
- GemBootstrap::GitUtils
- Defined in:
- lib/gem_bootstrap/git_utils.rb
Class Method Summary collapse
-
.create_git_project(base_dir, gem_name) ⇒ Object
create new git repository from a given directory.
-
.git_add(base_dir, files) ⇒ Object
Add files and perform initial commit to the repository.
-
.git_init(base_dir) ⇒ Object
Run the ‘git init` on a given directory.
Class Method Details
.create_git_project(base_dir, gem_name) ⇒ Object
create new git repository from a given directory
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gem_bootstrap/git_utils.rb', line 8 def create_git_project(base_dir, gem_name) base_dir = (base_dir) files = MiscUtils.files base_dir: base_dir, non_exts: %w(Gemfile Rakefile Guardfile LICENSE .rubocop.yml .yardopts .gitignore) << gem_name, exts: %w(md rb gemspec yml), recursive: true git_init(base_dir) git_add(base_dir, files) end |
.git_add(base_dir, files) ⇒ Object
Add files and perform initial commit to the repository
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gem_bootstrap/git_utils.rb', line 38 def git_add(base_dir, files) base_dir = (base_dir) Dir.chdir(base_dir) do git = Grit::Repo.new(File.('.')) files.each do |file| git.add(file) end git.commit_index('Initial commit') end end |
.git_init(base_dir) ⇒ Object
Run the ‘git init` on a given directory
27 28 29 30 31 32 |
# File 'lib/gem_bootstrap/git_utils.rb', line 27 def git_init(base_dir) base_dir = (base_dir) # Note: need to be in the right directory for this to work Dir.chdir(base_dir) MiscUtils.shell(%w(git init) << base_dir) end |