Method: Bones::App::Git#initialize_github

Defined in:
lib/bones/app/git.rb

#initialize_githubObject

Raises:

  • (::Bones::App::Error)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/bones/app/git.rb', line 62

def initialize_github
  return unless @config[:github]

  user = Git.global_config['github.user']
  token = Git.global_config['github.token']

  raise ::Bones::App::Error, 'A GitHub username was not found in the global configuration.' unless user
  raise ::Bones::App::Error, 'A GitHub token was not found in the global configuration.' unless token

  Net::HTTP.post_form(
      URI.parse('http://github.com/api/v2/yaml/repos/create'),
      'login' => user,
      'token' => token,
      'name' => name,
      'description' => @config[:github_desc]
  )

  @git.add_remote 'origin', "[email protected]:#{user}/#{name}.git"
  @git.config 'branch.master.remote', 'origin'
  @git.config 'branch.master.merge', 'refs/heads/master'
  @git.push 'origin'
end