Sha256: 3b5b9882247944a83c15fc49b67f5699c0fc1958d56dd50c9959d4b63f00cca5

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

desc 'Setup your GitHub account'
command :setup do |c|
  c.desc 'sets up your api token with GitHub'
  c.switch [:l, :local], default_value: false, desc: 'setup GitReflow for the current project only'
  c.switch [:e, :enterprise], default_value: false, desc: 'setup GitReflow with a Github Enterprise account'
  c.action do |global_options, options, args|
    reflow_options             = { project_only: options[:local], enterprise: options[:enterprise] }
    existing_git_include_paths = GitReflow::Config.get('include.path', all: true).split("\n")

    unless File.exist?(GitReflow::Config::CONFIG_FILE_PATH) or existing_git_include_paths.include?(GitReflow::Config::CONFIG_FILE_PATH)
      GitReflow.run "touch #{GitReflow::Config::CONFIG_FILE_PATH}"
      GitReflow.say "Created #{GitReflow::Config::CONFIG_FILE_PATH} for Reflow specific configurations", :notice
      GitReflow::Config.add "include.path", GitReflow::Config::CONFIG_FILE_PATH, global: true
      GitReflow.say "Added #{GitReflow::Config::CONFIG_FILE_PATH} to ~/.gitconfig include paths", :notice
    end

    choose do |menu|
      menu.header = "Available remote Git Server services"
      menu.prompt = "Which service would you like to use for this project?  "

      menu.choice('GitHub')    { GitReflow::GitServer.connect reflow_options.merge({ provider: 'GitHub', silent: false }) }
      menu.choice('BitBucket (team-owned repos only)') { GitReflow::GitServer.connect reflow_options.merge({ provider: 'BitBucket', silent: false }) }
    end

    GitReflow::Config.add "constants.minimumApprovals", ask("Set the minimum number of approvals (leaving blank will require approval from all commenters): "), local: reflow_options[:project_only]
    GitReflow::Config.add "constants.approvalRegex", GitReflow::GitServer::PullRequest::DEFAULT_APPROVAL_REGEX, local: reflow_options[:project_only]
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_reflow-0.7.5 lib/git_reflow/commands/setup.rb