Sha256: 3023591f8d4481fdca37a64d471d52fad733ec4eef8e8e27c60c0d8b5d481a32

Contents?: true

Size: 1.34 KB

Versions: 26

Compression:

Stored size: 1.34 KB

Contents

require 'thor'
require 'fwtoolkit/cli/fw_actions'
require 'fwtoolkit/git_client'
require 'fwtoolkit/cli/thorutils'

module FWToolkit
  class Git < Thor
    include Thor::Actions
    include FWToolkit::ThorUtils

    source_root_templates!

    desc 'new', 'Creates a git repository and commits to master all the files in project_dir'
    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

    desc 'update', 'Updates submodules for the repository in project_dir'
    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
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
fwtoolkit-2.6.4 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.6.3 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.6.2 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.6.1 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.6.0 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.5.0 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.4.0 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.6 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.5 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.4 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.3 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.2 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.1 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.3.0 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.2.4 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.2.3 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.2.2 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.2.1 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.2.0 lib/fwtoolkit/cli/git.rb
fwtoolkit-2.1.10 lib/fwtoolkit/cli/git.rb