knife-github 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjlkZjA5N2EwMzNiMTllZjkxY2I1MmQyNjE3MjhjZjFhYzRlN2Y0Ng==
4
+ ZWUwODg1N2Y4MTRjNjBkNDRkMTgxNWUxZmNmMDlmYzAwZmE4YWRmYw==
5
5
  data.tar.gz: !binary |-
6
- ZGE0NGViMjM1ODY5ZGU0NzU3ZGJhYzY0NGZkYjkyZjI5MWJlZDI3YQ==
6
+ NDBjNmYxOGVmYzUyYmI0NDRkN2ZhMGY5NGU4NWJmZmRiZWQ4YWQzMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2Q3ZDMyNGFlZWMxNDFjYzFhOGRjNmQyMzE4NDhhYTkzZGNkYjllMDY3N2U2
10
- MTc0OWMyNWJkZjFmMDQ0YWJhNGEzM2QyZGNjZTg4NzBjZjMzYTAxZWVlYTgy
11
- ZTg0MjM4YmQ5NWQ4ZGQxMmIwZDI0NjAzNDMxNjIwMGZkNDk5MGI=
9
+ ZmQ2Y2Q3OWZjYjdjNjk0ZjBiMDk2ZDY3N2MyY2JjYmUwZTc1OTYwNzRkNTFj
10
+ M2E0MWUyMzYyMTMzYWI1NGM3ZmQ3ZjRjYmY0OGFhNmFhNDY0YTAzODA5NmYx
11
+ ZTExYTQxMDA3ZTIxZWM1YzdkNWY1NWFmOGRiNzk2OTIzYmUyODc=
12
12
  data.tar.gz: !binary |-
13
- YjU1NWE3ZjY1MjdmNWNlN2UxYmQ5MjdkNTljMjMwYTE0YTkwMzI1NjBkMzA3
14
- ZjNlYzcxYTNmYmIzYzk3ZmZiMTU5ODAxMGYxNjFiNWFmMWU4ODg2OWQ5YjVl
15
- NDVlZDllYjVmOTJjZWNhYzU1ZDg5Y2Q3N2ZiNWM3ODQyNWFkMWQ=
13
+ NWE3OGFhOWVkMThmOTYzNTQxOTRjMDNlYTdlZWI1ZDQ0YWM4Njc0Zjc0MzM2
14
+ MDJiNDNmZjdiYmRlMGU3YWQxMzNiOTYyNTAyZjIwYWE0Zjg0OWIwOGEzODhk
15
+ NzYwZjZhMmYzZjdiMDRiMWUzMmQ1MDJhYmY0NDhjOTA0YTg0MDc=
@@ -102,11 +102,22 @@ module KnifeGithubRepoCreate
102
102
  # Creating the github repository
103
103
  Chef::Log.debug("Creating the github repository")
104
104
  repo = connection.request(params)
105
- github_ssh_url = repo['ssh_url']
106
-
107
- Chef::Log.debug("Commit and push local repository")
105
+ if @github_url =~ /^https:\/\/.*$/
106
+ token = get_github_token
107
+ if token.nil? || token.empty?
108
+ github_connection_url = repo['html_url']
109
+ else
110
+ uri = URI.parse(repo['html_url'])
111
+ uri.userinfo = "#{token}:x-oauth-basic"
112
+ github_connection_url = URI.join(uri)
113
+ end
114
+ else
115
+ github_connection_url = repo['ssh_url']
116
+ end
117
+
118
+ Chef::Log.debug("Commit and push local repository, using URL: #{github_connection_url}")
108
119
  # Initialize the local git repo
109
- git_commit_and_push(cookbook_dir, github_ssh_url)
120
+ git_commit_and_push(cookbook_dir, github_connection_url)
110
121
 
111
122
  puts "Finished creating #{name} and uploading #{cookbook_dir}"
112
123
  else
@@ -121,11 +132,22 @@ module KnifeGithubRepoCreate
121
132
  # Creating the github repository
122
133
  Chef::Log.debug("Creating the github repository")
123
134
  repo = connection.request(params)
124
- github_ssh_url = repo['ssh_url']
125
-
126
- Chef::Log.debug("Commit and push local repository")
135
+ if @github_url =~ /^https:\/\/.*$/
136
+ token = get_github_token
137
+ if token.nil? || token.empty?
138
+ github_connection_url = repo['html_url']
139
+ else
140
+ uri = URI.parse(repo['html_url'])
141
+ uri.userinfo = "#{token}:x-oauth-basic"
142
+ github_connection_url = URI.join(uri)
143
+ end
144
+ else
145
+ github_connection_url = repo['ssh_url']
146
+ end
147
+
148
+ Chef::Log.debug("Commit and push local repository, using URL: #{github_connection_url}")
127
149
  # Initialize the local git repo
128
- git_commit_and_push(cookbook_dir, github_ssh_url)
150
+ git_commit_and_push(cookbook_dir, github_connection_url)
129
151
 
130
152
  Chef::Log.debug("Removing temp files")
131
153
  FileUtils.remove_entry(@github_tmp)
@@ -184,8 +206,8 @@ module KnifeGithubRepoCreate
184
206
 
185
207
  # Set the username in README.md
186
208
  # @param cookbook_path [String] cookbook path
187
- # github_ssh_url [String] github ssh url from repo
188
- def git_commit_and_push(cookbook_path, github_ssh_url)
209
+ # github_url [String] github ssh url from repo
210
+ def git_commit_and_push(cookbook_path, github_url)
189
211
  if File.exists?(File.join(cookbook_path, ".git"))
190
212
  shell_out("git remote rm origin", :cwd => cookbook_path)
191
213
  else
@@ -194,7 +216,7 @@ module KnifeGithubRepoCreate
194
216
  shell_out!("echo - $(date): Uploaded with knife github plugin. >> CHANGELOG.md ", :cwd => cookbook_path)
195
217
  shell_out!("git add .", :cwd => cookbook_path)
196
218
  shell_out!("git commit -m 'creating initial cookbook structure from the knife-github plugin' ", :cwd => cookbook_path)
197
- shell_out!("git remote add origin #{github_ssh_url} ", :cwd => cookbook_path)
219
+ shell_out!("git remote add origin #{github_url} ", :cwd => cookbook_path)
198
220
  shell_out!("git push -u origin master", :cwd => cookbook_path)
199
221
  end
200
222
 
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Github
3
- VERSION = "0.1.8"
3
+ VERSION = "0.1.9"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sander Botman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-04 00:00:00.000000000 Z
12
+ date: 2015-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mixlib-versioning