Sha256: c13501106406d6a0cba7c948cc50303633fb1ff81a7f93fe5dbe5aa18f7999a9

Contents?: true

Size: 1.56 KB

Versions: 12

Compression:

Stored size: 1.56 KB

Contents

require 'thor'

module Creategem
  module Git
    include Thor::Actions

    def create_local_git_repository
      say "Create local git repository", :green
      run "git init"
      run "git add ."
      run "git commit -aqm 'Initial commit'"
    end

    def create_remote_git_repository(repository)
      say "Create remote #{repository.vendor} repository", :green
      if repository.github?
        run "curl -u '#{repository.user}' https://api.github.com/user/repos -d '{\"name\":\"#{repository.name}\"}'"
      else
        run "curl --request POST --user #{repository.user} https://api.bitbucket.org/1.0/repositories/ --data name=#{repository.name} --data scm=git --data is_private=true"
      end
      run "git remote add origin #{repository.origin}"
      say "Push initial commit to remote #{repository.vendor} repository", :green
      run "git push -u origin master"
    end

    def git_repository_user_name(vendor)
      git_config_key = "creategem.#{vendor}user"
      user = ::Git.global_config(git_config_key)
      if user.nil? || user.empty?
        user = ask("What is your #{vendor} user name?")
        ::Git.global_config(git_config_key, user)
      end
      user
    end

    def gem_server_url(vendor)
      if vendor == :github
        "https://rubygems.org"
      else
        git_config_key = "creategem.gemserver"
        url = ::Git.global_config(git_config_key)
        if url.nil? || url.empty?
          url = ask("What is the url of your geminabox server?")
          ::Git.global_config(git_config_key, url)
        end
        url
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
creategem-0.4.4 lib/creategem/git.rb
creategem-0.4.3 lib/creategem/git.rb
creategem-0.4.2 lib/creategem/git.rb
creategem-0.4.1 lib/creategem/git.rb
creategem-0.4.0 lib/creategem/git.rb
creategem-0.3.4 lib/creategem/git.rb
creategem-0.3.3 lib/creategem/git.rb
creategem-0.3.2 lib/creategem/git.rb
creategem-0.3.1 lib/creategem/git.rb
creategem-0.3.0 lib/creategem/git.rb
creategem-0.2.4 lib/creategem/git.rb
creategem-0.2.3 lib/creategem/git.rb