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 repo from a given directory.
- .git_add(files, options = {}) ⇒ Object
-
.git_init(options = {}) ⇒ Object
Run the git init on a given directory.
Class Method Details
.create_git_project(base_dir, gem_name) ⇒ Object
create new git repo from a given directory
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gem_bootstrap/git_utils.rb', line 9 def create_git_project(base_dir, gem_name) base_dir = File.(base_dir) # so that it works with ~/codes/etc 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: base_dir) git_add(files, base_dir: base_dir, gem_name: gem_name) end |
.git_add(files, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gem_bootstrap/git_utils.rb', line 36 def git_add(files, = {}) base_dir = File.([:base_dir]) Dir.chdir(base_dir) do git = Grit::Repo.new(File.(".")) files.each do |file| # puts "Add '#{file}' to repository" git.add(file) end git.commit_index("Initial commit") end end |
.git_init(options = {}) ⇒ Object
Run the git init on a given directory
28 29 30 31 32 33 34 |
# File 'lib/gem_bootstrap/git_utils.rb', line 28 def git_init( = {}) current_dir = File.([:base_dir]) base_dir = [:base_dir] || Dir.pwd Dir.chdir(base_dir) MiscUtils.shell(%w[git init] << base_dir) Dir.chdir(current_dir) end |