Class: FWToolkit::Git

Inherits:
Thor
  • Object
show all
Includes:
ThorUtils, Thor::Actions
Defined in:
lib/fwtoolkit/cli/git.rb

Instance Method Summary collapse

Methods included from ThorUtils

included

Methods included from Thor::Actions

#run, #run!, #run_base, #template_directory

Instance Method Details

#new(project_root) ⇒ Object

Raises:

  • (Thor::Error)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fwtoolkit/cli/git.rb', line 14

def new(project_root)
  destination_root = project_root
  repository = GitClient::Repository.new(project_root)
  raise Thor::Error, "There's already a repository at path: \"#{project_root}\"" if repository.initialized?

  template_directory 'templates/default_project/git', destination_root
  begin
    repository.init
    repository.add_files_to_index
    repository.commit('First commit')
    repository.switch_branch('dev')
  rescue GitClient::GitError => e
    raise Thor::Error, e.message + "\n#{e.git_output}"
  end

end

#update(project_root) ⇒ Object

Raises:

  • (Thor::Error)


32
33
34
35
36
37
38
39
40
41
# File 'lib/fwtoolkit/cli/git.rb', line 32

def update(project_root)
  repository = GitClient::Repository.new(project_root)
  raise Thor::Error, "There's no initialized repository at path: #{project_root}" unless git_repo.initialized?

  begin
    repository.submodule_update :init => true
  rescue GitError => e
    raise Thor::Error, e.message + "\n#{e.git_output}"
  end
end