Class: Github
Instance Method Summary
collapse
Methods included from GitConfig
#author, #email, #github_token, #github_user, #jenkins_password, #jenkins_server, #jenkins_user
Instance Method Details
#attach ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/github.rb', line 48
def attach
github_post "/#{github_user}/#{name}/edit/postreceive_urls",
"urls[]" => "#{jenkins_server}/job/#{name}/build?token=#{options.token}",
:raw => true
announce "attached github project to jenkins"
rescue => e
puts e
abort "failed in attach"
end
|
#delete_project ⇒ Object
21
22
23
24
25
26
|
# File 'lib/github.rb', line 21
def delete_project
abort "set --confirm to show you really mean it" unless options.confirm?
res = github_post("/repos/delete/#{github_user}/#{name}", :name => name)
delete_token = JSON.parse(res.body)['delete_token']
github_post("/repos/delete/#{github_user}/#{name}", :name => name, :delete_token => delete_token)
end
|
#new_project ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/github.rb', line 29
def new_project
Dir.chdir name do
guarded "git init"
guarded "git add ."
guarded "git commit -m 'initial commit'" do end
github_post('/repos/create', :name => name)
guarded "git remote add origin [email protected]:#{github_user}/#{name}"
announce "new project on github"
end
end
|
#preflight ⇒ Object
12
13
14
15
16
17
|
# File 'lib/github.rb', line 12
def preflight
abort "you already have a #{name} project on github" unless
HTTParty.get("http://github.com/#{github_user}/#{name}").code == 404
github_user
github_token
end
|
#push ⇒ Object
41
42
43
|
# File 'lib/github.rb', line 41
def push
Dir.chdir(name) { guarded "git push -u origin master" }
end
|