Coder Social home page Coder Social logo

guyzmo / git-repo Goto Github PK

View Code? Open in Web Editor NEW
838.0 29.0 86.0 1.03 MB

Git-Repo: CLI utility to manage git services from your workspace

Home Page: https://webchat.freenode.net/?channels=#git-repo

License: Other

Python 98.40% Shell 1.60%
git cli python gitlab bitbucket github cli-utilities pypi gist snippet pull-request issue utility gogs gitea python3

git-repo's Introduction

Git-Repo: git services CLI utility

Looking for help

For the past few months I've been really busy coding on stuff that puts food on the table… And sadly, I cannot give this project all the love it deserves. Which is why it's taken me months to spend a few hours merge and release the PRs featured in this repository.

I'm still using this project daily, but I'm not having enough time to keep on putting all the effort needed to make it shine (SSH keys, issues support…)

So I'd like to share the maintenance responsibility with someone or more people. If you're interested, please ping me on IRC or by mail (which is in all my commits). I'm always happy to guide through the code's design!

Usage

main commands

Control your remote git hosting services from the git commandline. The usage is very simple (full usage list in the sources). To clone a new project, out of GitHub, just issue:

% git hub clone guyzmo/git-repo

But that works also with a project from GitLab, Bitbucket, your own GitLab or Gogs:

% git lab clone guyzmo/git-repo
% git bb clone guyzmo/git-repo
% git myprecious clone guyzmo/git-repo
% git gg clone guyzmo/git-repo

If you want to choose the default branch to clone:

% git lab clone guyzmo/git-repo master

Though sometimes, as you're starting a new project, you want to create a new repository to push to:

% git hub create guyzmo/git-repo

actually the namespace is facultative, as per default you can (and want to) only create new repositories within your own account.

You might also want to add an existing remote ref to your workspace, and that can be easily done with:

% git lab add guyzmo/git-repo

Which will add https://gitlab.com/guyzmo/git-repo as the gitlab remote!

Also, you can fork a repository using:

% git hub fork neovim/neovim

and of course, you can delete it using:

% git bb delete guyzmo/git-repo

Also, you can open the repository's page, using the open command:

% git lab open guyzmo/git-repo
Successfully fetched branch `2` of `guyzmo/git-repo` into `request-2`!

Requests for merges (aka Pull Requests aka Merge Requests)

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

% git hub request guyzmo/git-repo list
List of open requests to merge:
id     title                                                           URL
2     prefer gitrepo.<target>.token > privatekey, docs                https://api.github.com/repos/guyzmo/git-repo/issues/2

And fetch it locally to check and/or amend it before merging:

% git hub request guyzmo/git-repo fetch 2

Or you can create a request by doing a:

% git hub request create guyzmo/git-repo myfeature master -t 'My neat feature' -m 'So much to say about that feature…'

You can create the request also by simply calling:

% git hub request create

That command has a bit of automagic, it will:

  1. lookup the namespace and project of the current branch (or at least on the github remote, if called with hub), and take this as the source of the request ;
  2. for the target of the request it will lookup and take:
  • the parent if current project has a parent
  • or itself, if does not ;
  1. it will take the currently loaded branch for the source
  2. and the default one for the target
  3. call the service to ask for a request to merge from source onto target.

Gists or snippets

Finally, another extra feature you can play with is the gist handling:

% git hub gist list
id                                                              title
https://gist.github.com/4a0dd9177524b2b125e9166640666737        This is a test gist

Then you can list files within it:

% git hub gist list a7ce4fddba7744ddf335
language         size  name
Python           1048  unicode_combined.py
% git hub -v gist list https://gist.github.com/4a0dd9177524b2b125e9166640666737
language         size  name
Markdown         16    README.md
Text             14    LICENSE
reStructuredText 17    README.rst

to output it locally, you can use the fetch command (and specify the file if there's more than one):

% git hub gist fetch https://gist.github.com/a7ce4fddba7744ddf335 > mygist.py
% git hub gist fetch 4a0dd9177524b2b125e9166640666737 LICENSE > LICENSE_from_gist

but for more thorough modifications or consulting, you can as well clone it:

% git hub gist clone 4a0dd9177524b2b125e9166640666737
Pulling from github |████████████████████████████████|
Successfully cloned `4a0dd9177524b2b125e9166640666737` into `./4a0dd9177524b2b125e9166640666737`!

And when you're done you just get rid of it:

% git hub gist -f delete 4a0dd9177524b2b125e9166640666737
Successfully deleted gist!

Nota Bene: Thanks to git CLI flexibility, by installing git-repo you directly have access to the tool using git-repo hub … or git repo hub …. For the git hub … call, you have to set up aliases, see below how to configure that.

Remotes

Traditionally, origin is being used as the remote name for the code hosted on a service, but because of the nature of git-repo there is no single origin but it encourages to use multiple ones, and also leave you in control of wherever origin points to.

This is why when you clone from a service or create a new repo on a service, it's using a special remote that carries the name of the service:

% git hub clone foo/bar; cd bar
% git status -sb | head -1
## master...github/master
            ^^^^^^
% git lab create bar
% git push gitlab master

And as a bonus, each time it's adding a new remote, it's updating the all remote, so that you can push your code to all your remote repositories in one command:

% git push all master

Another special remote is the upstream. When you do a fork of a project, current special remote with a service name will be renamed as upstream and the newly forked project is now the one with the service name:

% git lab clone foo/bar; cd bar
% git remote
all
gitlab
% git lab fork
% git remote
all
gitlab
upstream

Finally, if you want to link other existing projects, you can, the add command is there for that:

% git bb add foo/bar
% # if the name is identical to current project, you don't need to add a name
% git hub add
% git gg add foo/bar gitea --alone

Use the --alone switch if you don't want to add that project in the all special remote.

And of course the above commands is just sugar around regular git commands, so the above can also be done with:

% git remote add gitbucket https://gitbucket.local:8080/foo/bar
% # the command to append the URL to the all remote, --alone skips this step
% git remote set-url --add all https://gitbucket.local:8080/foo/bar

And to remove a remote, just do:

% git remote remove github

Installation

You can get the tool using pypi (use pip3 if you have both Python2 and Python3 installed):

% pip install git-repo

or by getting the sources and running:

% python3 setup.py install

Configuration

To configure git-repo you simply have to call the following command:

% git repo config

and a wizard will run you through getting the authentication token for the service, add the command alias or the name of the remote. Though, configuring custom services is still not handled by the wizard…

But if you prefer manual configuration you'll have to tweak your ~/.gitconfig. For each service you've got an account on, you have to make a section in the gitconfig:

[gitrepo "gitlab"]
    token = YourVerySecretKey

[gitrepo "github"]
    token = YourOtherVerySecretKey

[gitrepo "bitbucket"]
    username = ford.prefect
    token = YourSecretAppKey

[gitrepo "gogs"]
    fqdn = UrlOfYourGogs
    token = YourVerySecretKey

Here, we're setting the basics: just the private token. Notice that the token needed for Bitbucket are an App-token, not to be confused with an OAuth-token, which are also avaiable from the Butbucket settings.

You also have the ability to set up an alias:

[gitrepo "bitbucket"]
    alias = bit
    username = ford.prefect
    token = YourSecretAppKey

that will change the command you use for a name you'll prefer to handle actions for the service you use:

% git-repo bit clone guyzmo/git-repo

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

[gitrepo "myprecious"]
    type = gitlab
    token = YourSuperPrivateKey
    fqdn = gitlab.example.org
    # Set this only if you use a self-signed certificate and experience problems
    insecure = true

Finally, to make it really cool, you can make a few aliases in your gitconfig:

[alias]
    hub = repo hub
    lab = repo lab
    bb = repo bb
    perso = repo perso

So you can run the tool as a git subcommand:

git hub clone guyzmo/git-repo

For those who like to keep all dotfiles in a git repository, it'd be horrendous to store tokens that offer access to your social accounts in a repository… And I'm not even talking about those who want to share your dotfiles. But don't worry, once it's all configured, you can fire up your favorite editor and move all the [gitrepo …] sections into a new file, like ~/.gitconfig-repos.

Your can run the following command to do this automagically:

python -m git_repo.extract_config

if you want to use another path, you can change the defaults:

python -m git_repo.extract_config ~/.gitconfig-repos ~/.gitconfig

Configuring Gerrit

Please note: when configuration wizard will ask you for password, do not provide your Gerrit account password, but enter HTTP password instead. You can setup it on Settings > HTTP Password page

You may also need to tweak your ~/.gitconfig:

  • set ro-suffix if your Gerrit isn't served at server root. For example, set ro-suffix to /r if your Gerrit is hosted at https://review.host.com/r
  • set ssh-port parameter to set custom port for ssh connection to Gerrit (default: 29418)
  • set auth-type: basic (default) or digest

Development

For development, start a virtualenv and from within install the devel requirements:

% virtualenv var
% var/bin/pip install -r requirements-test.txt

and then you'll have the executable in bin:

% var/bin/git-repo --help

and to run the tests:

% var/bin/py.test --cov=git_repo --cov-report term-missing --capture=sys tests

N.B.: Buildout is no longer supported for development

Verbose running

You can repeat the -v argument several times to increase the level of verbosity of git-repo. The more arguments you give, the more details you'll have.

  • -v will set the debugging level to DEBUG, giving some execution info ;
  • -vv will print out all the git commands that are being executed ;
  • -vvv will give more verbose insight on the git layer ;
  • -vvvv will output all the HTTP exchanges with the different APIs ;
  • -vvvvv will printout how were parsed the arguments.
Testing

To run the tests:

% bin/py.test

You can use the following options for py.test to help you debug when tests fail:

  • -v will show more details upon errors
  • -x will stop upon the first failure
  • --pdb will launch the debugger where an exception has been launched

The tests use recordings of exchanged HTTP data, so that we don't need real credentials and a real connection, when testing the API on minor changes. Those recordings are called cassettes, thanks to the betamax framework being in use in the test suites.

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

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

  • GITHUB_NAMESPACE (which defaults to not_configured) is the name of the account to use on GitHub
  • GITLAB_NAMESPACE (which defaults to not_configured) is the name of the account to use on GitLab
  • BITBUCKET_NAMESPACE (which defaults to not_configured) is the name of the account to use on Bitbucket
  • GOGS_NAMESPACE (which defaults to not_configured) is the name of the account to use on Gogs
  • PRIVATE_KEY_GITHUB your private token you've setup on GitHub for your account
  • PRIVATE_KEY_GITLAB your private token you've setup on GitLab for your account
  • PRIVATE_KEY_BITBUCKET your private token you've setup on Bitbucket for your account
  • PRIVATE_KEY_GOGS your private token you've setup on Gogs for your account

TODO

  • make a git-repo fork action
  • make it possible to choose method (SSH or HTTPS)
  • handle default branches properly
  • make a nice way to push to all remotes at once
  • refactor the code into multiple modules
  • add regression tests (and actually find a smart way to implement them…)
  • add travis build
  • show a nice progress bar, while it's fetching (cf #15)
  • add support for handling gists (cf #12, cf #13)
  • add support for handling pull requests (cf #10, #11)
  • add application token support for bitbucket (cf #14)
  • add support for gogs (cf #18)
  • add support for gitbucket (cf #142)
  • add support for managing SSH keys (cf #22)
  • add support for issues (cf #104)
  • add support for gerrit (cf #19)
  • do what's needed to make a nice documentation #146
  • for more features, write an issue or, even better, a PR!

Contributors

The project and original idea has been brought and is maintained by:

With code contributions coming from:

License

Copyright ©2016,2017 Bernard `Guyzmo` Pratz <[email protected]>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See the LICENSE file for the full license.

git-repo's People

Contributors

allanlrh avatar amandacameron avatar benzaita avatar buaazp avatar crazybus avatar dmerejkowsky avatar frankrousseau avatar guyzmo avatar jayvdb avatar king6cong avatar kounoike avatar nikitavbv avatar peterazmanov avatar pyhedgehog avatar razer6 avatar rnestler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-repo's Issues

Improve progress bar reporting

Currently progress bar is not really reporting progress (it's appearing at the end already at 100%). Something's wrong in the implementation between GitPython and my code, need to be investigated.

Add request create support

implement:

git-repo <target> request <user/repo> create [<branch>] <title> --message=<description>

which makes a new pull request with current branch.

provider prompt ordering

Thanks for the great tool!

Re-running git repo config has the potential to leak credentials since it seems to randomise which provider it prompts for input for first.

If a lazy user (such as myself) isn't careful and doesn't re-read the prompts on each run due to expecting the order to be the same (as is usually the case for wizards) then it's possible to input the credentials for a provider other than the one you're expecting. The result is that secrets are potentially submitted to the wrong provider which is probably a security concern.

Support full URL as repo_slug

For more convenience, support full URL repo-slugs the same way we support short repo-slugs. Useful for copy/pasting (even if redundant in some cases with canonical git command).

Add SSH key upload feature

add a command to upload SSH keys to the service, something like:

git <target> ssh push <ssh-public-key-file>
git <target> ssh ls
git <target> ssh delete <ssh-public-key-id>

the whole point being to make it easy to generate a new key (or even rotate keys!) or revoke an old key with the CLI.

Ideas for a new name? (was: This repo is impossible to search)

I stumbled across this awesome tool while reading hackernews and then a few months later tried to find it took me ages! I had to go through heaps of combinations of search terms before i stumbled across it again. Even now that I have found it, when I searched for it by name git-repo it still doesn't show in google.

Have you thought about changing the name? it would be great if more people could find this!

git repo <target> ls for listing a user's repositories

I would really like functionality to get a list of all git repos under a given account, preferably in a format easy to parse in scripts and with multiple formatting options (i.e. format as git ssh urls, format as https urls, append default branch or not).

I'm currently using a hand-rolled tool (chegit) to keep my local changes synced to Gitlab, but I don't have tooling for multiple remotes yet (your 'all' remote would solve this), and I don't have a way of getting a list of remote repositories that I might want to keep a local copy of.

Is this functionality already included and did I overlook it in the help page, and if not, would you consider implementing it?

GitLab gitrepo doesn't work with self-hosted instance

I wanted to setup a custom gitlab service, so I edited my .gitconfig to include the following section:

[gitrepo "selfhosted"]
        fqdn = mygitlab.example.org
        type = gitlab
        token = SUPER_SECRET

Then when I tried to create a repo I got a "401 Unauthorized" error. I generated a new token just in case it was wrong but that didn't seem to be the problem... I also made sure my instance's GitLab API was working by testing it with curl etc.

Then I thought that maybe git-repo tries to authenticate with another server, so I changed the personal token from my instance to a one generated for my gitlab.com account, and it worked (the repository was created on gitlab.com).

So even when specifying an fqdn in the config file, git-repo still tries to communicate with the default GitLab server, gitlab.com. With the appropriate .gitconfig, gitlab.com and github work fine though.

I should also state that I tried both the latest version from pypi and the master branch and the issue remains.

Tests failing randomly

The tests are failing since the introduction of the --progress support. The issue being inconsistent failing of the same code between calls. Cf the travis reports.

With a fair bit of debugging, I found out the issue is that because GitPython relies on the kwargs construct to pass around optional arguments, the order of argument will depend on the order of the items within the dict. As when I introduced progress support, opt_arg contains '-v' and '--progress' now, the order depending on both hash('-v') and hash('--progress'). To fix this, making the optional arguments ordered on their value instead on their hash will do the job, but sadly it's not something that can be fixed with a tiny bit of monkey patching…

Thus, I've opened a PR upstream at gitpython-developers/GitPython#431 with a very simple fix for that.

Food for thought: v2 redesign

Current code offers a clean and easy to implement API. But as more features gets integrated, the more the help page becomes cluttered. So a redesign of the code would be a good idea to think about.

Also, integrating new services means sensitively increasing the code base. Not everybody wants to use all existing services at once, and implementing new services shouldn't be tied to the main code base: if you want to implement support for Gogs (for example) you shouldn't ask for my permission (by doing fork+PR)!

So the main things I'm thinking to change for a possible V2 redesign are modularizing the CLI API, and extracting the services as external plugins.

Subcommands for the CLI API

So the goal would be to modularize the code for each subcommand, so that each feature comes as an independent module coming with its own help page.

As currently, each service lies in its own module, that would mean implementing a "two axis" modularization: for each service and for each command. Then the main help page would have to be generated and the output would look like:

Usage:
    git-repo [--path=<path>] [-v...] <target> <command> [options]

Options:
    <target>            service to use, using the alias (hub, lab or bb),
    <command>           command to trigger, use --help on that command to see usage.
    --path              repository to use

Commands:
    fork                 Fork a project
    create               Create a new project on the service
    delete               Delete an existing project from the service
    open                 Open the project's page with your browser
    gist                 Manage gists
    request              Manage requests

The best way to do that, would be to have for each feature a module and class following this template:

'''
git-repo : Manage gists from the service 

Usage:
    gist (list|ls) [<gist>]
    gist clone <gist>
    gist fetch <gist> [<gist_file>]
    gist create [--secret] <description> [<gist_path> <gist_path>...]
    gist delete <gist> [-f]

Commands:
    ...
'''

@register_interface
class RepositoryServiceClone:
    def get_service(self, lookup_repository):
        raise NotImplementedError

    def clone(self, user, repo, branch):
        raise NotImplementedError

@register_command('clone', __doc__)
class GitRepoCommandClone:
    def do_clone(self):
        service = self.get_service(lookup_repository=False)
        repo_path = os.path.join(self.path, self.repo_name)
        if os.path.exists(repo_path):
            raise FileExistsError('Cannot clone repository, '
                                  'a folder named {} already exists!'.format(repo_path))
        repository = Repo.init(repo_path)
        service = RepositoryService.get_service(repository, self.target)
        service.clone(self.user_name, self.repo_name, self.branch)
        log.info('Successfully cloned `{}` into `{}`!'.format(
            service.format_path(self.repo_slug),
            repo_path)
        )
        return 0

Then, each service would inherit from each interface offered by a command, raising NotImplementedError exceptions when it does not offer an implementation. All missing implementation for interfaces would be easy to list, though.

Then we could have a change in namespace so it becomes:

git_repo.commands.clone
git_repo.commands.fork
git_repo.commands.create
git_repo.commands.delete
git_repo.commands.open
git_repo.commands.gist
git_repo.commands.request

Use a plugin approach for services

To make it easier to implement new services, they could be offered as independent packages, that would populate in the git_repo.services.ext namespace, and be automagically loaded by git-repo when installed. Then one could only have the code for a single service at any time.

Remove gitlab monkey patching

As gitlab has been fixed with a patch to support requests sessions, remove the monkey patching hack in the gitlab tests.

Make requests for merges not needing repo slug

Make it possible to "guess" the repo slug of the current repository so the user doesn't have to give full repo slug when listing PR of current directory, i.e. instead of:

% git hub guyzmo/git-repo clone
% cd git-repo
% git hub guyzmo/git-repo request list

make it possible to do:

% git hub guyzmo/git-repo clone 
% cd git-repo
% git hub request list

I guess the strategy would be to look for the fqdn value in URLs of all the remotes and when found, regex it to get the repo-slug!

Unable to install on MacOSX

sudo pip install git+https://github.com/guyzmo/git-repo.git
The directory '/Users/Sandeep/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/Sandeep/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting git+https://github.com/guyzmo/git-repo.git
  Cloning https://github.com/guyzmo/git-repo.git to /tmp/pip-Cah3BZ-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-Cah3BZ-build/setup.py", line 67
        class Version(Command, metaclass=VersionInfo):
                                        ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-Cah3BZ-build/

Add auto-configuration command

create a command to autoconfigure git-repo, which would be:

git repo configure (github|gitlab|bitbucket)

which would then run an authentication loop, to query auth tokens, asking for user/pass for both github and gitlab, and record login:pass for bitbucket (until oauth config is implemented).
Eventually, it could ask for custom gitlab URLs as well.

and it would then populate ~/.gitconfig with:

alias.hub = repo hub
alias.lab = repo lab
alias.bb = repo bb

Here's a mockup of how the interactions could be:

% git repo configure
• Do you want to configure github access? 
[Yn]> Y
Enter your username: 
'guyzmo'> foobar
Enter your password:
>
Please wait while getting authenticated…
Done, cheers! 🍻
• Do you want to configure gitlab access?
[Yn]> Y
Enter your username: 
'$USER'> barfoo
Enter your password:
>
Please wait while getting authenticated…
Done, cheers! 🍻
• Do you want to configure bitbucket access?
[Yn]> Y
Enter your username: 
'$USER'> fubar
Enter your password:
>
Done, cheers! 🍻
• Do you want to add a custom gitlab access?
[yN]> Y
Enter the URL of the gitlab:
> https://my_gitlab.my_domain.tld
Enter the short name of the service:
> mine
Enter your username:
'$USER'> ford.prefect
Enter your password:
>
Please wait while getting authenticated…
Done, cheers! 🍻
• Do you want to add a custom gitlab access?
[yN]> n
Thank you, here's your configuration:
Service   | Name | Username     | Password | Token    | URI
--------- | ---- | ------------ | -------- | -------- | -----
Github    | hub  | foobar       | *        | Acquired | *
Gitlab    | lab  | barfoo       | *        | Acquired | *
Bitbucket | bb   | fubar        | Acquired | *        | *
Gitlab    | mine | ford.prefect | *        | Acquired | https://my_gitlab.my_domain.tld

Support for GitHub appliances

University of Minnesota uses a local GitHub appliance instead of public GitHub. Would be fantastic to get this working against it.

Authentication failure on gitlab server using private key authentication

I failed to authenticate with a private key.

This is what I have stored in my .gitconfig

[gitrepo "gitlabxxx"]
    alias = xxx
    type = gitlab
    token = ~/.ssh/id_rsa_gitlabxxx
    fqdn = gitlab.xxx.fr

I also defined the alias xxx = repo xxx.

The following instruction works:

$ git clone [email protected]:yyyy/myProject.git

And this is what I tried to do which failed

$ git xxx clone yyyy/myProject
Fatal error: Can't connect to GitLab server ([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645))

I also tried to create a new github repo to test and it failed with the following error

$ git hub create yyyy/test
Fatal error: 'GithubService' object has no attribute 'username'

This is what I have defined in .gitconfig for github

[gitrepo "github"]
    alias = hub
    token = ~/.ssh/id_rsa_github

In my ~/.ssh/config file I have

Host github.com
  User git
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_github
  IdentitiesOnly yes

I didn't need that for the gitlab server.

Ability to assign pull request to a github user

My usual workflow when creating a pull request is to assign it to a collaborator. Right now, using git hub request create doesn't save me much time because I still have to open up github.com to assign the PR. It would be great if I could pass an -a <username> parameter to git hub request create to automatically assign the PR when it's created.

Adding gist support

Let's create a new set of commands for gist support, with following usage:

git-repo [--path=<path>] [-v -v...] <target> gist list [<gist>]                                              
git-repo [--path=<path>] [-v -v...] <target> gist clone <gist>                               
git-repo [--path=<path>] [-v -v...] <target> gist fetch <gist> [<gist_file>]
git-repo [--path=<path>] [-v -v...] <target> gist create [--secret] <description> [<gist_path> <gist_path>...]
git-repo [--path=<path>] [-v -v...] <target> gist delete <gist> [-f]

that can list all gists and files within a gist, clone a gist, or fetch a gist's file contents, create a new gist or simply delete it.

Crashes because of overly specific gitpython dependency

I installed git-repo using sudo pip3 install git-repo on a debian sid x64 system. However, upon launching it crashes:

$ git repo config
Traceback (most recent call last):
  File "/usr/local/bin/git-repo", line 7, in <module>
    from git_repo.repo import cli
  File "/usr/local/lib/python3.5/dist-packages/git_repo/repo.py", line 112, in <module>
    __version__ = pkg_resources.require('git-repo')[0].version
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 970, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 861, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (GitPython 2.0.8 (/home/phihag/.local/lib/python3.5/site-packages), Requirement.parse('GitPython==2.0.6'), {'git-repo'})

I have GitPython 2.0.8 installed since I need it for various other projects. The changes in 2.0.8 are all fixes of annoying bugs. Why do I need to downgrade my GitPython installation to a buggy one in order to use git-repo?

Switch CLI API dispatch framework to `docopt_dispatch`

The current command dispatch code has been designed to avoid an over-complex main function. But it was after coding it that I discovered that the author of docopt implemented a similar framework he called docopt_dispatch.

That framework might need some adjustments for custom features built in the current command dispatch code, but it's worth using an existing and common framework than reinventing the wheel.

Is the version in requirements.txt mandatory?

Hi,

I'm making an archlinux PKGBUILD for git-repo. However the requirements.txt claim for certain version of those dependencies.

Is the version in requirements.txt mandatory, or the requirements can be greater than or equal to (>=)?

Thank you for your time.

Make help documentation more concise

Current documentation is way too verbose (29 lines, cf __doc__), and it could be written as follows (16 lines!):

Usage:
    {self} [--path=<path>] [-v...] <target> fork [<user>/<repo>] [<branch>] [--clone]
    {self} [--path=<path>] [-v...] <target> create [<user>/<repo>] [--add]
    {self} [--path=<path>] [-v...] <target> delete [<user>/<repo>] [-f]
    {self} [--path=<path>] [-v...] <target> open [<user>/<repo>]
    {self} [--path=<path>] [-v...] <target> clone <user>/<repo> [<branch>]
    {self} [--path=<path>] [-v...] <target> add <user>/<repo> [<name>] [--tracking=<branch>] [-a]
    {self} [--path=<path>] [-v...] <target> request [<user>/<repo>] (list|ls)
    {self} [--path=<path>] [-v...] <target> request [<user>/<repo>] fetch <request>
    {self} [--path=<path>] [-v...] <target> request [<user>/<repo>] create [<remote_branch> [<local_branch>]] <title> [--branch=<remote>] [--message=<message>]
    {self} [--path=<path>] [-v...] <target> gist (list|ls) [<gist>]
    {self} [--path=<path>] [-v...] <target> gist clone <gist>
    {self} [--path=<path>] [-v...] <target> gist fetch <gist> [<gist_file>]
    {self} [--path=<path>] [-v...] <target> gist create [--secret] <description> [<gist_path> <gist_path>...]
    {self} [--path=<path>] [-v...] <target> gist delete <gist> [-f]
    {self} [--path=<path>] [-v...] [<target>] config [--config=<gitconfig>]
    {self} --help

The issue lies within docopt and I've opened an issue about it. Let's hope we'll find a way.

Another approach would be to consider changing the approach of the help page, by going through a refactoring of the current CLI API design, which could be considered for v2.

Refactor fork command

Improvement of the fork command to have a more natural API.
New API idea (using github as example):

  1. git hub fork
    • if current directory is a repository
      • lookup the upstream's URL, make a fork, add the fork as remote
    • otherwise, just fail loudly
  2. git hub fork user/repo
    • fork the repository on the server and do not mutate local filesystem
  3. git hub fork user/repo path
    • if path exists
      • make the fork and add the fork as remote
    • if path does not exists
      • clone the upstream, make the fork and add the fork as remote

so in the end, you can have a scenario where you've cloned a repository, found a bug and want to fork it, you can:

git hub clone foo/bar
cd bar
# fix a bug, make a commit
git hub fork
git hub push github master # will push to your fork

but if you've cloned a fork, and you want to push to the upstream of that fork, and you know the path to that upstream:

git hub clone foo/bar
cd bar
# fix a bug, make a commit
git hub fork fu/bar . # the path that the fork command shall modify
git hub push github master

if you want to fork a project and clone it elsewhere:

git hub fork foo/bar /path/to/elsewhere

(and if elsewhere is an existing repository, then update it).

or finally, you want to fork a project, but think about cloning it another time:

git hub fork foo/bar

which won't touch the filesystem, just the remote service.

Adding requests for merge support

Add the request subcommand that enables handling of requests:

git-repo [--path=<path>] [-v -v...] <target> request [<user>/<repo>] list
git-repo [--path=<path>] [-v -v...] <target> request [<user>/<repo>] fetch <request>

that makes it possible to list all requests, and fetch a request thanks to its id.

Not working after pip3 install git-repo

I followed the installation instructions in the Readme file.
After installation, git repo config is not recognized by git as a valid git command. Same problem with git hub.

There is apparently a missing installation step in the documentation.

GitHub 2FA support

I have 2FA enabled on my GitHub account. When I ran git repo config, this happened:

Do you want to configure the github service?
    [Yn]> y
Please enter your credentials to connect to the service:
username> tcby45
password>
Fatal error: 401 Must specify two-factor authentication OTP code.

Could you please either include a 2FA check on the account (then a prompt for the code), or possibly ask whether to authenticate by personal access token or user/pass?

Installation with pip --user

Hey,
I would like to install 'git-repo' but I prefer to install in my userspace with pip install --user,
here is the error I get

pip install --user git-repo                                                                                                                                                                       1 
Collecting git-repo
  Downloading git-repo-1.4.tar.gz
    Complete output from command python setup.py egg_info:

    Installed /tmp/pip-build-4e20i_j2/git-repo/.eggs/setuptools_markdown-0.2-py3.4.egg
    Searching for pypandoc
    Reading https://pypi.python.org/simple/pypandoc/
    Best match: pypandoc 1.1.3
    Downloading https://pypi.python.org/packages/source/p/pypandoc/pypandoc-1.1.3.zip#md5=771f376bf9c936a90159cd94235998c2
    Processing pypandoc-1.1.3.zip
    Writing /tmp/easy_install-tobd_snv/pypandoc-1.1.3/setup.cfg
    Running pypandoc-1.1.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tobd_snv/pypandoc-1.1.3/egg-dist-tmp-g5fpg11a
    zip_safe flag not set; analyzing archive contents...
    pypandoc.__pycache__.__init__.cpython-34: module references __file__
    Patching wheel building...
    creating /tmp/pip-build-4e20i_j2/git-repo/.eggs/pypandoc-1.1.3-py3.4.egg
    Extracting pypandoc-1.1.3-py3.4.egg to /tmp/pip-build-4e20i_j2/git-repo/.eggs

    Installed /tmp/pip-build-4e20i_j2/git-repo/.eggs/pypandoc-1.1.3-py3.4.egg
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-4e20i_j2/git-repo/setup.py", line 38, in <module>
        zip_safe=False
      File "/usr/lib64/python3.4/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib64/python3.4/site-packages/setuptools/dist.py", line 272, in __init__
        _Distribution.__init__(self,attrs)
      File "/usr/lib64/python3.4/distutils/dist.py", line 280, in __init__
        self.finalize_options()
      File "/usr/lib64/python3.4/site-packages/setuptools/dist.py", line 327, in finalize_options
        ep.load()(self, ep.name, value)
      File "/tmp/pip-build-4e20i_j2/git-repo/.eggs/setuptools_markdown-0.2-py3.4.egg/setuptools_markdown.py", line 22, in long_description_markdown_filename
        output = pypandoc.convert(markdown_filename, 'rst')
      File "/tmp/pip-build-4e20i_j2/git-repo/.eggs/pypandoc-1.1.3-py3.4.egg/pypandoc/__init__.py", line 50, in convert
        outputfile=outputfile, filters=filters)
      File "/tmp/pip-build-4e20i_j2/git-repo/.eggs/pypandoc-1.1.3-py3.4.egg/pypandoc/__init__.py", line 68, in _convert
        raise RuntimeError('Missing format!')
    RuntimeError: Missing format!

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4e20i_j2/git-repo

I think it should work ( I do the same for other user-managed packages ), so maybe there is a problem in the pypy recipe ?

Can't clone into current working directory even when it is empty

When trying to clone to current working directory git-repo complains that the folder already exists.

git lab clone project/repo .
Fatal error: Cannot clone repository, a folder named ./. already exists!

With git this is allowed assuming that the directory is empty. If the directory is not empty git complains with:

fatal: destination path '.' already exists and is not an empty directory.

Proposal: Use the same logic as git to allow for cloning into empty already existing directories. (PR incoming)

Implement gitlab 2FA support

The same way github's 2FA support has been recently added (cf #39) implement gitlab's 2FA as well.

Even though implementing 2FA with github was easy thanks to @sigmavirus24's work on sigmavirus24/github3.py where it was already implemented… Doing it on gitlab needs to start with patching gpocentex/python-gitlab to implement a 2FA callback… Looking at the code it looks like there's no mechanism in place for that yet:

That being said, it is unclear how to use 2FA and whether a mechanism is in place for using it with Gitlab's API, as there's no mention of 2FA in the authentication section of the Gitlab API documentation.

Adding default settings for new repositories creation

There is git-repo config that I am trying not to confuse. This issue is about configuring GitHub, GitLab, Bitbucket and not configuring git-repo. Maybe this is out of scope and fits in better with something such as Terraform.io

Problem:
Repos will have a handful of settings, such as enabled services, branch protection, webhooks, merge types, mirroring, etc. Click though web gui introduces inconsistencies and other disadvantages.

If my org were to primarily use GitLab but mirror on GitHub then there are two namespaces to clear and two different configurations to deal with.

Proposed:
Configuration of provider repos in yaml, json (with comments, just minify to strip first), or toml.
A cmd to act on the configuration file such as hub|lab|bit|all create|update|remove

git all create would create whatever repos are configured, in my case, github and gitlab.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.