Package: git-repo
Git-Repo: git services CLI utility-----------------------------------  To get the sources:-  https://github.com/guyzmo/git-repo-  https://gitlab.com/guyzmo/git-repo-  https://bitbucket.org/guyzmo/git-repo-  Issues: https://github.com/guyzmo/git-repo/issues-  Meet the community, come chat:-  on IRC: [#git-repo@freenode](https://webchat.freenode.net/?channels=#git-repo)-  on Matrix:`#git-repo:matrix.org <https://riot.im/app/#/room/#git-repo:matrix.org>`__-  on Gitter:`git-services/git-repo <https://gitter.im/git-services/git-repo>`__-  |Issues in Ready| |Issues in Progress| |Show Travis Build Status|-  `|Pypi Version| |PypiDownloads| <https://pypi.python.org/pypi/git-repo>`__Looking for help----------------For the past few months I've been really busy coding on stuff that putsfood on the table… And sadly, I cannot give this project all the love itdeserves. Which is why it's taken me months to spend a few hours mergeand release the PRs featured in this repository.I'm still using this project daily, but I'm not having enough time tokeep on putting all the effort needed to make it shine (SSH keys, issuessupport…)So I'd like to share the maintenance responsibility with someone or morepeople. If you're interested, please ping me on IRC or by mail (which isin 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 thesources <https://github.com/guyzmo/git-repo/blob/devel/git_repo/repo.py#L4,L35>`__).To clone a new project, out of GitHub, just issue:::% git hub clone guyzmo/git-repoBut that works also with a project from GitLab, Bitbucket, your ownGitLab 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-repoIf you want to choose the default branch to clone:::% git lab clone guyzmo/git-repo masterThough sometimes, as you're starting a new project, you want to create anew repository to push to:::% git hub create guyzmo/git-repoactually the namespace is facultative, as per default you can (and wantto) only create new repositories within your own account.You might also want to add an existing remote ref to your workspace, andthat can be easily done with:::% git lab add guyzmo/git-repoWhich will add ``https://gitlab.com/guyzmo/git-repo`` as the ``gitlab``remote!Also, you can fork a repository using:::% git hub fork neovim/neovimand of course, you can delete it using:::% git bb delete guyzmo/git-repoAlso, you can open the repository's page, using the ``open`` command:::% git lab open guyzmo/git-repoSuccessfully 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 tomerge (aka Pull Requests on github) using the ``request`` command:::% git hub request guyzmo/git-repo listList of open requests to merge:id     title                                                           URL2     prefer gitrepo.<target>.token > privatekey, docs                https://api.github.com/repos/guyzmo/git-repo/issues/2And fetch it locally to check and/or amend it before merging:::% git hub request guyzmo/git-repo fetch 2Or 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 createThat command has a bit of automagic, it will:1. lookup the namespace and project of the current branch (or at leaston the ``github`` remote, if called with ``hub``), and take this asthe 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 ;3. it will take the currently loaded branch for the source4. and the default one for the target5. call the service to ask for a request to merge from source ontotarget.Gists or snippets^^^^^^^^^^^^^^^^^Finally, another extra feature you can play with is the gist handling:::% git hub gist listid                                                              titlehttps://gist.github.com/4a0dd9177524b2b125e9166640666737        This is a test gistThen you can list files within it:::% git hub gist list a7ce4fddba7744ddf335language         size  namePython           1048  unicode_combined.py% git hub -v gist list https://gist.github.com/4a0dd9177524b2b125e9166640666737language         size  nameMarkdown         16    README.mdText             14    LICENSEreStructuredText 17    README.rstto output it locally, you can use the fetch command (and specify thefile 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_gistbut for more thorough modifications or consulting, you can as well cloneit:::% git hub gist clone 4a0dd9177524b2b125e9166640666737Pulling from github |████████████████████████████████|Successfully cloned `4a0dd9177524b2b125e9166640666737` into `./4a0dd9177524b2b125e9166640666737`!And when you're done you just get rid of it:::% git hub gist -f delete 4a0dd9177524b2b125e9166640666737Successfully 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 codehosted on a service, but because of the nature of ``git-repo`` there isno single ``origin`` but it encourages to use multiple ones, and alsoleave you in control of wherever ``origin`` points to.This is why when you clone from a service or create a new repo on aservice, it's using a special remote that carries the name of theservice:::% git hub clone foo/bar; cd bar% git status -sb | head -1## master...github/master^^^^^^% git lab create bar% git push gitlab masterAnd 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 remoterepositories in one command:::% git push all masterAnother special remote is the ``upstream``. When you do a fork of aproject, current special remote with a service name will be renamed as``upstream`` and the newly forked project is now the one with theservice name:::% git lab clone foo/bar; cd bar% git remoteallgitlab% git lab fork% git remoteallgitlabupstreamFinally, 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 --aloneUse 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 gitcommands, 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/barAnd to remove a remote, just do:::% git remote remove githubInstallation~~~~~~~~~~~~You can get the tool using pypi (use ``pip3`` if you have both Python2and Python3 installed):::% pip install git-repoor by getting the sources and running:::% python3 setup.py installConfiguration~~~~~~~~~~~~~To configure ``git-repo`` you simply have to call the following command:::% git repo configand a wizard will run you through getting the authentication token forthe 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 tomake a section in the gitconfig:::[gitrepo "gitlab"]token = YourVerySecretKey[gitrepo "github"]token = YourOtherVerySecretKey[gitrepo "bitbucket"]username = ford.prefecttoken = YourOtherSecretKey[gitrepo "gogs"]fqdn = UrlOfYourGogstoken = YourVerySecretKeyHere, we're setting the basics: just the private token. You'll noticethat for bitbucket the private token is your username and passwordseperated by a column. That's because bitbucket does not offer throwaway private tokens for tools (I might implement BB's OAuth at somepoint).You also have the ability to set up an alias:::[gitrepo "bitbucket"]alias = bitusername = ford.prefecttoken = YourOtherSecretKeythat will change the command you use for a name you'll prefer to handleactions for the service you use:::% git-repo bit clone guyzmo/git-repoAlso, you can setup your own GitLab self-hosted server, using thatconfiguration:::[gitrepo "myprecious"]type = gitlabtoken = YourSuperPrivateKeyfqdn = gitlab.example.org# Set this only if you use a self-signed certificate and experience problemsinsecure = trueFinally, to make it really cool, you can make a few aliases in yourgitconfig:::[alias]hub = repo hublab = repo labbb = repo bbperso = repo persoSo you can run the tool as a git subcommand:::git hub clone guyzmo/git-repoFor those who like to keep all dotfiles in a git repository, it'd behorrendous to store tokens that offer access to your social accounts ina repository… And I'm not even talking about those who want to shareyour dotfiles. But don't worry, once it's all configured, you can fireup your `favorite editor <http://www.vim.org>`__ 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_configif you want to use another path, you can change the defaults:::python -m git_repo.extract_config ~/.gitconfig-repos ~/.gitconfigDevelopment~~~~~~~~~~~For development, start a virtualenv and from within install the develrequirements:::% virtualenv var% var/bin/pip install -r requirements-test.txtand then you'll have the executable in ``bin``:::% var/bin/git-repo --helpand to run the tests:::% var/bin/py.test --cov=git_repo --cov-report term-missing --capture=sys testsN.B.: *Buildout is no longer supported for development*Verbose running^^^^^^^^^^^^^^^You can repeat the ``-v`` argument several times to increase the levelof verbosity of ``git-repo``. The more arguments you give, the moredetails you'll have.-  ``-v`` will set the debugging level to ``DEBUG``, giving someexecution 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 differentAPIs ;-  ``-vvvvv`` will printout how were parsed the arguments.Testing'''''''To run the tests:::% bin/py.testYou can use the following options for py.test to help you debug whentests fail:-  ``-v`` will show more details upon errors-  ``-x`` will stop upon the first failure-  ``--pdb`` will launch the debugger where an exception has beenlaunchedThe tests use recordings of exchanged HTTP data, so that we don't needreal credentials and a real connection, when testing the API on minorchanges. Those recordings are called cassettes, thanks to the`betamax <https://github.com/sigmavirus24/betamax>`__ framework being inuse in the test suites.When running existing tests, based on the provided cassettes, you don'tneed any setting. Also, if you've got a configuration in``~/.gitconfig``, the tests will use them. Anyway, you can useenvironment variables for those settings (environment variables willhave precedence over the configuration settings):To use your own credentials, you can setup the following environmentvariables:-  ``GITHUB_NAMESPACE`` (which defaults to ``not_configured``) is thename of the account to use on GitHub-  ``GITLAB_NAMESPACE`` (which defaults to ``not_configured``) is thename of the account to use on GitLab-  ``BITBUCKET_NAMESPACE`` (which defaults to ``not_configured``) is thename of the account to use on Bitbucket-  ``GOGS_NAMESPACE`` (which defaults to ``not_configured``) is the nameof the account to use on Gogs-  ``PRIVATE_KEY_GITHUB`` your private token you've setup on GitHub foryour account-  ``PRIVATE_KEY_GITLAB`` your private token you've setup on GitLab foryour account-  ``PRIVATE_KEY_BITBUCKET`` your private token you've setup onBitbucket for your account-  ``PRIVATE_KEY_GOGS`` your private token you've setup on Gogs for youraccountTODO~~~~-  [x] make a ``git-repo fork`` action-  [x] make it possible to choose method (SSH or HTTPS)-  [x] handle default branches properly-  [x] make a nice way to push to all remotes at once-  [x] refactor the code into multiple modules-  [x] add regression tests (and actually find a smart way to implementthem…)-  [x] add travis build-  [x] show a nice progress bar, while it's fetching (cf`#15 <https://github.com/guyzmo/git-repo/issues/15>`__)-  [x] add support for handling gists (cf`#12 <https://github.com/guyzmo/git-repo/issues/12>`__, cf`#13 <https://github.com/guyzmo/git-repo/issues/13>`__)-  [x] add support for handling pull requests (cf`#10 <https://github.com/guyzmo/git-repo/issues/10>`__,`#11 <https://github.com/guyzmo/git-repo/issues/11>`__)-  [x] add application token support for bitbucket (cf`#14 <https://github.com/guyzmo/git-repo/issues/14>`__)-  [x] add support for gogs (cf`#18 <https://github.com/guyzmo/git-repo/issues/18>`__)-  [x] add support for gitbucket (cf`#142 <https://github.com/guyzmo/git-repo/issues/142>`__)-  [ ] add support for managing SSH keys (cf`#22 <https://github.com/guyzmo/git-repo/issues/22>`__)-  [ ] add support for issues (cf`#104 <https://github.com/guyzmo/git-repo/issues/104>`__)-  [ ] add support for gerrit (cf`#19 <https://github.com/guyzmo/git-repo/issues/19>`__)-  [ ] do what's needed to make a nice documentation`#146 <https://github.com/guyzmo/git-repo/issues/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:-  Bernard [@guyzmo](https://github.com/guyzmo) Pratz —`commits <https://github.com/guyzmo/git-repo/commits?author=guyzmo>`__With code contributions coming from:-  [@PyHedgehog](https://github.com/pyhedgehog) —`commits <https://github.com/guyzmo/git-repo/commits?author=pyhedgehog>`__-  [@guyhughes](https://github.com/guyhughes) —`commits <https://github.com/guyzmo/git-repo/commits?author=guyhughes>`__-  [@buaazp](https://github.com/buaazp) —`commits <https://github.com/guyzmo/git-repo/commits?author=buaazp>`__-  [@peterazmanov](https://github.com/peterazmanov) —`commits <https://github.com/guyzmo/git-repo/commits?author=peterazmanov>`__-  [@Crazybus](https://github.com/Crazybus) —`commits <https://github.com/guyzmo/git-repo/commits?author=Crazybus>`__-  [@rnestler](https://github.com/rnestler) —`commits <https://github.com/guyzmo/git-repo/commits/devel?author=rnestler>`__-  [@jayvdb](https://github.com/jayvdb) —`commits <https://github.com/guyzmo/git-repo/commits/devel?author=jayvdb>`__-  [@kounoike](https://github.com/kounoike) —`commits <https://github.com/guyzmo/git-repo/commits/devel?author=kounoike>`__-  [@AmandaCameron](https://github.com/AmandaCameron) —`commits <https://github.com/guyzmo/git-repo/commits/devel?author=AmandaCameron>`__-  [@fa7ad](https://github.com/fa7ad) —`commits <https://github.com/guyzmo/git-repo/commits/devel?author=fa7ad>`__License~~~~~~~::Copyright ©2016,2017 Bernard `Guyzmo` Pratz <guyzmo+git-repo+pub@m0g.net>This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.See the LICENSE file for the full license.♥.. |Issues in Ready| image:: https://badge.waffle.io/guyzmo/git-repo.png?label=ready&title=Ready:target: https://waffle.io/guyzmo/git-repo.. |Issues in Progress| image:: https://badge.waffle.io/guyzmo/git-repo.png?label=in%20progress&title=Progress:target: https://waffle.io/guyzmo/git-repo.. |Show Travis Build Status| image:: https://travis-ci.org/guyzmo/git-repo.svg:target: https://travis-ci.org/guyzmo/git-repo.. |Pypi Version| image:: https://img.shields.io/pypi/v/git-repo.svg.. |Pypi Downloads| image:: https://img.shields.io/pypi/dm/git-repo.svg