gitpython allows me work on git working copies. i'd use it. how fetch unique part, i.e. "abbreviated ref id", using gitpython?
so interested in --abbrev-commit option git log gives me (e.g. in git log --abbrev-commit --pretty=oneline -n 1).
how can in gitpython - or have implement enumerating through ref ids , figuring out required length on own?
the following code example on how use git rev-parse --short functionality gitpython:
import git r = git.repo() short = r.git.rev_parse(r.head, short=true) print(short) # u'f360ecd' it appears using git-command preferable on implementing in safe fashion.
a naive pure-python implementation though:
r.head.commit.hexsha[:7] however, doesn't check if obtained prefix unique @ time of creation, why git-command based approach should preferred.
Comments
Post a Comment