- Notifications
You must be signed in to change notification settings - Fork90
Git-Repo: CLI utility to manage git services from your workspace
License
guyzmo/git-repo
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
- To get the sources:
- Issues:https://github.com/guyzmo/git-repo/issues
- Meet the community, come chat:
- on IRC:#git-repo @freenode
- on Matrix:#git-repo:matrix.org
- on Gitter:git-services/git-repo
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 monthsto 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 theeffort 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'reinterested, please ping me on IRC or by mail (which is in all my commits). I'm always happyto guide through the code's design!
Control your remote git hosting services from thegit commandline. The usage isvery simple (full usage listin the sources). 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 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-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 a newrepository to push to:
% git hub create guyzmo/git-repoactually 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 thatcan be easily done with:
% git lab add guyzmo/git-repoWhich will addhttps://gitlab.com/guyzmo/git-repo as thegitlab 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 theopen command:
% git lab open guyzmo/git-repoSuccessfully fetched branch `2` of `guyzmo/git-repo` into `request-2`!Once you're all set with your repository, you can check requests to merge(aka Pull Requests on github) using therequest 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:
- lookup the namespace and project of the current branch (or at least on the
githubremote, if called withhub), and take this as the source of the request ; - for the target of the request it will lookup and take:
- the parent if current project has a parent
- or itself, if does not ;
- it will take the currently loaded branch for the source
- and the default one for the target
- call the service to ask for a request to merge from source onto target.
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 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_gistbut for more thorough modifications or consulting, you can as well clone it:
% 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
gitCLI flexibility, by installinggit-repoyou directlyhave access to the tool usinggit-repo hub …orgit repo hub …. For thegit hub …call, you have to set up aliases, see below how to configure that.
Traditionally,origin is being used as the remote name for the code hosted on aservice, but because of the nature ofgit-repo there is no singleorigin butit encourages to use multiple ones, and also leave you in control of whereverorigin 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 masterAnd as a bonus, each time it's adding a new remote, it's updating theall remote,so that you can push your code to all your remote repositories in one command:
% git push all masterAnother special remote is theupstream. When you do a fork of a project, currentspecial remote with a service name will be renamed asupstream and the newlyforked project is now the one with the service 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, theadd commandis 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 theallspecial 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/barAnd to remove a remote, just do:
% git remote remove githubYou can get the tool using pypi (usepip3 if you have both Python2 and Python3 installed):
% pip install git-repoor by getting the sources and running:
% python3 setup.py installTo configuregit-repo you simply have to call the following command:
% git repo configand a wizard will run you through getting the authentication token for theservice, add the command alias or the name of the remote. Though, configuringcustom 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 asection in the gitconfig:
[gitrepo "gitlab"] token = YourVerySecretKey[gitrepo "github"] token = YourOtherVerySecretKey[gitrepo "bitbucket"] username = ford.prefect token = YourSecretAppKey[gitrepo "gogs"] fqdn = UrlOfYourGogs token = YourVerySecretKeyHere, 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 = YourSecretAppKeythat will change the command you use for a name you'll prefer to handle actionsfor the service you use:
% git-repo bit clone guyzmo/git-repoAlso, 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 = trueFinally, 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 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 be horrendous tostore tokens that offer access to your social accounts in a repository… And I'm noteven talking about those who want to share your dotfiles. But don't worry, onceit's all configured, you can fire up yourfavorite editor andmove 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 ~/.gitconfigPlease note: when configuration wizard will ask you for password, do not provideyour Gerrit account password, but enterHTTP password instead. You can setupit onSettings > HTTP Password page
You may also need to tweak your~/.gitconfig:
- set
ro-suffixif your Gerrit isn't served at server root. For example, setro-suffixto/rif your Gerrit is hosted athttps://review.host.com/r - set
ssh-portparameter to set custom port for ssh connection to Gerrit (default: 29418) - set
auth-type: basic (default) or digest
For development, start a virtualenv and from within install the devel requirements:
% virtualenv var% var/bin/pip install -r requirements-test.txtand then you'll have the executable inbin:
% 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
You can repeat the-v argument several times to increase the level of verbosityofgit-repo. The more arguments you give, the more details you'll have.
-vwill set the debugging level toDEBUG, giving some execution info ;-vvwill print out all the git commands that are being executed ;-vvvwill give more verbose insight on the git layer ;-vvvvwill output all the HTTP exchanges with the different APIs ;-vvvvvwill printout how were parsed the arguments.
To run the tests:
% bin/py.testYou can use the following options for py.test to help you debug when tests fail:
-vwill show more details upon errors-xwill stop upon the first failure--pdbwill launch the debugger where an exception has been launched
The tests use recordings of exchanged HTTP data, so that we don't need real credentialsand a real connection, when testing the API on minor changes. Those recordings arecalled cassettes, thanks to thebetamax frameworkbeing in use in the test suites.
When running existing tests, based on the provided cassettes, you don't need anysetting. Also, if you've got a configuration in~/.gitconfig, the tests will usethem. Anyway, you can use environment variables for those settings (environmentvariables will have precedence over the configuration settings):
To use your own credentials, you can setup the following environment variables:
GITHUB_NAMESPACE(which defaults tonot_configured) is the name of the account to use on GitHubGITLAB_NAMESPACE(which defaults tonot_configured) is the name of the account to use on GitLabBITBUCKET_NAMESPACE(which defaults tonot_configured) is the name of the account to use on BitbucketGOGS_NAMESPACE(which defaults tonot_configured) is the name of the account to use on GogsPRIVATE_KEY_GITHUByour private token you've setup on GitHub for your accountPRIVATE_KEY_GITLAByour private token you've setup on GitLab for your accountPRIVATE_KEY_BITBUCKETyour private token you've setup on Bitbucket for your accountPRIVATE_KEY_GOGSyour private token you've setup on Gogs for your account
- make a
git-repo forkaction - 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!
The project and original idea has been brought and is maintained by:
With code contributions coming from:
- @PyHedgehog —commits
- @guyhughes —commits
- @buaazp —commits
- @peterazmanov —commits
- @Crazybus —commits
- @rnestler —commits
- @jayvdb —commits
- @kounoike —commits
- @AmandaCameron —commits
- @fa7ad —commits
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.
♥
About
Git-Repo: CLI utility to manage git services from your workspace
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.

