GithubHelp home page GithubHelp logo

frace / git-passport Goto Github PK

View Code? Open in Web Editor NEW
108.0 108.0 25.0 720 KB

A Git command and hook written in Python to manage multiple Git accounts / user identities.

Home Page: https://github.com/frace/git-passport

License: Other

Python 100.00%

git-passport's People

Contributors

frace avatar holocronweaver 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

git-passport's Issues

Somewhat confusing dialog

There's no indicator of the index anymore if you merge in the multidomain support. There should be an indicator to the user which option to select.

Possibly merge config_read() and config_validate()

I'd get rid of the config_validate function and do that in config_read instead, using a separate config_read_passport or so, which then uses ConfigParser.getboolean and the other get... functions with a very strict schema, so you make sure that everything coming out of the config object is properly parsed. That way you have to write less verification code (as the ConfigParser object takes care of that for you) and you can spend that on making sure that the individual passports have the correct format before handing them off to the rest of the application.

Reference: http://codereview.stackexchange.com/a/77176

@Ferada
Do you talk about to define config_validate() as an inner function of config_read()?
Possibly would it make sense to transform config_validate() into a decorator function which then is used to decorate config_read()?

Why the "fancy" characters?

I kind of find the output with lots of irregular characters unexpected, but of course that's your choice.

Reference: http://codereview.stackexchange.com/a/77176

@Ferada
I wanted the messages to stand out from the usual Git output, so I decided to use some characters (~, leading period) for highlighting. I guess that worked out well. :) However the characters might change in the future.

Use argparse to accept commandline arguments

Examples:
-f / --force : Force to re-passport the current git repository even if there is a passport setup already
-c / --clean : Delete the active passport of the current git repository

Use less sys.exit() calls

Also, I would use less sys.exits in general. It is helpful if you can just import the script for testing purposes and it's jarring if using e.g. config_create suddenly kills the interpreter. Same for proper testing later.

Reference: http://codereview.stackexchange.com/a/77176

@Ferada
I understand the concerns in regards to testing and importing the script in the interpreter. However I just checked where I do call them. The point is that I really need them in situations where the script is used as a Git hook in order to quit a possible commit if something goes wrong with a Git ID/passport.

Unfortunately I don't see a way to reduce the number of calls of sys.exit()right now. The only thing I could think of is to introduce a enable_debug or enable_testing variable which lets us disable the sys.exit() calls conditionally.

pre-commit not called during git init

I tried git 1.9.* (several subversions) and 2.2.2, and none triggered the pre-commit hook during git init. The hooks were successfully copied from the templates folder, and triggered successfully when I tried to commit, but the README gives the impression a simple git init should trigger pre-commit. Is this a change in more recent git versions? If so, is there a hook that runs during git init, or is some other hook or method necessary?

Consider where to use sets instead of lists

Membership testing with sets and dictionaries is much faster, O(1), than searching sequences, O(n). When testing "a in b", b should be a set or dictionary instead of a list or tuple.

Reference: https://wiki.python.org/moin/PythonSpeed

Test:

In [4]: timeit.timeit('whitelist = [["General", "Passport"], ["email", "enable_hook", "name", "service", "sleep_duration"]]', number = 10000)
Out[4]: 0.010425090789794922

In [5]: timeit.timeit('whitelist = [{"General", "Passport"}, {"email", "enable_hook", "name", "service", "sleep_duration"}]', number = 10000)
Out[5]: 0.00904703140258789

Introduce a `git passport` command

Placing the script in a $PATH, e.g. /usr/local/bin/git-passport would extend the possibilities of usage. Executing git passport manually would call the script as ususal. Optionally users could link to the path and use it as a hook.

I have to test that...

urlparse doesn't always give 'base url'

In quite a few cases with my own repositories git-passport doesn't recognize the url correctly. This has to do with the use of urlparse. Some examples:

>>> from urllib.parse import urlparse

>>> urlparse('[email protected]:tverlaan/git-passport')
ParseResult(scheme='', netloc='', path='[email protected]:tverlaan/git-passport', params='', query='', fragment='')

>>> urlparse('github.com:tverlaan/git-passport')
ParseResult(scheme='github.com', netloc='', path='tverlaan/git-passport', params='', query='', fragment='')

>>> urlparse('https://github.com/tverlaan/git-passport.git')
ParseResult(scheme='https', netloc='github.com', path='/tverlaan/git-passport.git', params='', query='', fragment='')

I can think of two alternatives for fixing this issue:

  • string match between url in passport and git config url
  • improve url parsing

The first solution would also allow for automatic matching different usernames for different projects with the same base url (say github.com). I'm happy to issue a PR, but I wanted to discuss first.

Multiple services domains per passport

I want to use the same passport credentials across multiple service domains.

There are several ways I could think to accomplish this with git-passport. The easiest is to make the service field a delimited list of services. (I suggest comma-delimited since that is most common.) Alternatively, regex could be introduced. The latter could be useful for domains with multiple similar variations, though I haven't seen that much in the wild.

Error on setting Passport

For some reason using python 3.5.2 and git 2.7.4 on Max OX i get this error:

error: could not lock config file .git/config: File exists

And the file .git/config is not updated with the selection.

Wrap git "getters" into a single function

I'd wrap getting values from git in a separate function, maybe git_config_get, which would (for now) still use the same subprocess.Popen method with passed in arguments and then does the communicate/decode handling. And reraising the exception isn't necessary. Whether you create a separate git_config_set (instead of using the same mechanism as git config) is kind of a trade-off.

Reference: http://codereview.stackexchange.com/a/77176

Move textwrap.dedent(foo).strip() into its own function

textwrap.dedent(foo).strip() is nice, I'm copying that; since you use it very often I think that separate functions, like dedented or so, are in order; something short and simple. Same for lstrip.

Reference: http://codereview.stackexchange.com/a/77176

@Ferada
Do you mean to create a separate function like:

def dedented(message, strip_type):
    if strip_type == "strip":
        return textwrap.dedent(message).strip()
    elif strip_type == "lstrip":
        return textwrap.dedent(message).lstrip()
    elif strip_type == "rstrip":
        return textwrap.dedent(message).rstrip()
    else:
        return

Consecutive passport numbering

Is it necessary that the passport sections be consecutively numbered? If so, this could cause some tedium when removing an early entry in a long list of passports and having to -1 most of the sections.

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.