Skip to content

Commit 7e9bd2b

Browse files
committed
Merge branch 'bugfix/1.7.3' into devel
2 parents da5163e + 277f6ba commit 7e9bd2b

File tree

7 files changed

+48
-35
lines changed

7 files changed

+48
-35
lines changed

README.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
### main commands
1414

1515
Control your remote git hosting services from the `git` commandline. The usage is
16-
very simple. To clone a new project, out of github, just issue:
16+
very simple. To clone a new project, out of GitHub, just issue:
1717

1818
% git hub clone guyzmo/git-repo
1919

20-
But that works also with a project from gitlab, bitbucket, or your own gitlab:
20+
But that works also with a project from GitLab, Bitbucket, or your own GitLab:
2121

2222
% git lab clone guyzmo/git-repo
2323
% git bb clone guyzmo/git-repo
@@ -57,7 +57,7 @@ Also, you can open the repository's page, using the `open` command:
5757

5858
### Requests for merges *(aka Pull Requests aka Merge Requests)*
5959

60-
Once you're all set with your repository, you can check requests to merge
60+
Once you're all set with your repository, you can check requests to merge
6161
(aka Pull Requests on github) using the `request` command:
6262

6363
% git hub request guyzmo/git-repo list
@@ -109,7 +109,7 @@ And when you're done you just get rid of it:
109109
Successfully deleted gist!
110110

111111
> *Nota Bene*: Thanks to `git` CLI flexibility, by installing `git-repo` you directly
112-
> have acces to the tool using `git-repo hub …` or `git repo hub …`. For the
112+
> have access to the tool using `git-repo hub …` or `git repo hub …`. For the
113113
> `git hub …` call, you have to set up aliases, see below how to configure that.
114114
115115
And as a bonus, each time it's adding a new remote, it's updating the `all` remote,
@@ -166,7 +166,7 @@ for the service you use:
166166

167167
% git-repo bit clone guyzmo/git-repo
168168

169-
Also, you can setup your own gitlab self-hosted server, using that configuration:
169+
Also, you can setup your own GitLab self-hosted server, using that configuration:
170170

171171
[gitrepo "myprecious"]
172172
type = gitlab
@@ -188,7 +188,7 @@ So you can run the tool as a git subcommand:
188188
### Development
189189

190190
For development, I like to use `buildout`, and the repository is already configured
191-
for that. All you have to do, is install buildout, and then call it from the root of
191+
for that. All you have to do, is install buildout, and then call it from the root of
192192
the repository:
193193

194194
% pip install zc.buildout
@@ -198,6 +198,19 @@ and then you'll have the executable in `bin`:
198198

199199
% bin/git-repo --help
200200

201+
#### Verbose running
202+
203+
You can repeat the `-v` argument several times to increase the level of verbosity
204+
of `git-repo`. The more arguments you give, the more details you'll have.
205+
206+
* `-v` will set the debugging level to `DEBUG`, giving some execution info ;
207+
* `-vv` will print out all the git commands that are being executed ;
208+
* `-vvv` will give more verbose insight on the git layer ;
209+
* `-vvvv` will output all the HTTP exchanges with the different APIs ;
210+
* `-vvvvv` will printout how were parsed the arguments.
211+
212+
##### Testing
213+
201214
To run the tests:
202215

203216
% bin/py.test
@@ -208,25 +221,24 @@ You can use the following options for py.test to help you debug when tests fail:
208221
* `-x` will stop upon the first failure
209222
* `--pdb` will launch the debugger where an exception has been launched
210223

211-
212224
The tests use recordings of exchanged HTTP data, so that we don't need real credentials
213225
and a real connection, when testing the API on minor changes. Those recordings are
214226
called cassettes, thanks to the [betamax](https://github.com/sigmavirus24/betamax) framework
215227
being in use in the test suites.
216228

217-
When running existing tests, based on the provided cassettes, you don't need any
229+
When running existing tests, based on the provided cassettes, you don't need any
218230
setting. Also, if you've got a configuration in `~/.gitconfig`, the tests will use
219231
them. Anyway, you can use environment variables for those settings (environment
220232
variables will have precedence over the configuration settings):
221233

222234
To use your own credentials, you can setup the following environment variables:
223235

224-
* `GITHUB_NAMESPACE` (which defaults to `not_configured`) is the name of the account to use on github
225-
* `GITLAB_NAMESPACE` (which defaults to `not_configured`) is the name of the account to use on gitlab
226-
* `BITBUCKET_NAMESPACE` (which defaults to `not_configured`) is the name of the account to use on bitbucket
227-
* `PRIVATE_KEY_GITHUB` your private token you've setup on github for your account
228-
* `PRIVATE_KEY_GITLAB` your private token you've setup on gitlab for your account
229-
* `PRIVATE_KEY_BITBUCKET` your private token you've setup on bitbucket for your account
236+
* `GITHUB_NAMESPACE` (which defaults to `not_configured`) is the name of the account to use on GitHub
237+
* `GITLAB_NAMESPACE` (which defaults to `not_configured`) is the name of the account to use on GitLab
238+
* `BITBUCKET_NAMESPACE` (which defaults to `not_configured`) is the name of the account to use on Bitbucket
239+
* `PRIVATE_KEY_GITHUB` your private token you've setup on GitHub for your account
240+
* `PRIVATE_KEY_GITLAB` your private token you've setup on GitLab for your account
241+
* `PRIVATE_KEY_BITBUCKET` your private token you've setup on Bitbucket for your account
230242

231243
### TODO
232244

@@ -256,7 +268,7 @@ To use your own credentials, you can setup the following environment variables:
256268

257269
### License
258270

259-
Copyright Bernard `Guyzmo` Pratz <[email protected]>
271+
Copyright © Bernard `Guyzmo` Pratz <[email protected]>
260272

261273
This program is free software; you can redistribute it and/or
262274
modify it under the terms of the GNU General Public License

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.0
1+
1.7.2

git_repo/repo.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ def do_create(self):
355355
if not self.user_name and not self.repo_name:
356356
self.set_repo_slug('/'.join([service.user,
357357
os.path.basename(os.path.abspath(self.path))]))
358+
if not self.user_name:
359+
self.user_name = service.user
358360
service.create(self.user_name, self.repo_name, add=self.add)
359361
log.info('Successfully created remote repository `{}`, '
360362
'with local remote `{}`'.format(
@@ -532,10 +534,12 @@ def main(args):
532534
log.exception('------------------------------------')
533535
return 2
534536

535-
536-
537537
def cli(): #pragma: no cover
538-
sys.exit(main(docopt(__doc__.format(self=sys.argv[0].split('/')[-1], version=__version__))))
538+
try:
539+
sys.exit(main(docopt(__doc__.format(self=sys.argv[0].split('/')[-1], version=__version__))))
540+
finally:
541+
# Whatever happens, make sure that the cursor reappears with some ANSI voodoo
542+
sys.stdout.write('\033[?25h')
539543

540544
if __name__ == '__main__': #pragma: no cover
541545
cli()

git_repo/services/ext/github.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def __init__(self, *args, **kwarg):
2121
def connect(self):
2222
try:
2323
self.gh.login(token=self._privatekey)
24-
self.username = self.gh.user().name
25-
self.username = self.gh.user().name
24+
self.username = self.gh.user().login
2625
except github3.models.GitHubError as err:
2726
if err.code is 401:
2827
if not self._privatekey:
@@ -81,7 +80,7 @@ def _format_gist(self, gist):
8180

8281
def gist_list(self, gist=None):
8382
if not gist:
84-
for gist in self.gh.iter_gists(self.gh.user().name):
83+
for gist in self.gh.iter_gists(self.gh.user().login):
8584
yield (gist.html_url, gist.description)
8685
else:
8786
gist = self.gh.gist(self._format_gist(gist))
@@ -149,9 +148,9 @@ def request_create(self, user, repo, local_branch, remote_branch, title, descrip
149148
repository = self.gh.repository(user, repo)
150149
if not repository:
151150
raise ResourceNotFoundError('Could not find repository `{}/{}`!'.format(user, repo))
152-
if not local_branch:
153-
remote_branch = self.repository.active_branch.name or self.repository.active_branch.name
154151
if not remote_branch:
152+
remote_branch = self.repository.active_branch.name
153+
if not local_branch:
155154
local_branch = repository.master_branch or 'master'
156155
try:
157156
request = repository.create_pull(title,
@@ -160,15 +159,12 @@ def request_create(self, user, repo, local_branch, remote_branch, title, descrip
160159
body=description)
161160
except github3.models.GitHubError as err:
162161
if err.code == 422:
163-
for error in err.errors:
164-
if 'message' in error:
165-
if 'No commits' in error['message']:
162+
if err.message == 'Validation Failed':
163+
for error in err.errors:
164+
if 'message' in error:
166165
raise ResourceError(error['message'])
167-
else:
168-
if 'message' in error:
169-
raise ResourceError(error['message'])
170-
raise ResourceError("Unhandled formatting error: {}".format(err.errors))
171-
166+
raise ResourceError("Unhandled formatting error: {}".format(err.errors))
167+
raise ResourceError(err.message)
172168

173169
return {'local': local_branch, 'remote': remote_branch, 'ref': request.number}
174170

@@ -208,5 +204,5 @@ def get_auth_token(cls, login, password):
208204

209205
@property
210206
def user(self):
211-
return self.gh.user().name
207+
return self.gh.user().login
212208

git_repo/services/ext/gitlab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self, *args, **kwarg):
2020
super(GitlabService, self).__init__(*args, **kwarg)
2121

2222
def connect(self):
23+
self.gl.set_url(self.url_ro)
2324
self.gl.set_token(self._privatekey)
2425
self.gl.token_auth()
2526
self.username = self.gl.user.username

git_repo/services/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def format_path(self, repository, namespace=None, rw=False):
195195
elif rw and '/' in repo:
196196
return '{}:{}'.format(self.url_rw, repo)
197197
else:
198-
raise ArgumentError("Cannot tell how to handle this url: `{}/{}`!".format(user, repo_name))
198+
raise ArgumentError("Cannot tell how to handle this url: `{}/{}`!".format(namespace, repo))
199199

200200
def pull(self, remote, branch=None):
201201
'''Pull a repository

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
docopt
2-
GitPython==2.0.6
2+
GitPython>=2.0.6
33
progress==1.2
44
python-gitlab==0.13
55
uritemplate.py==2.0.0

0 commit comments

Comments
 (0)