go-git: Create short hash (a83ad00 instead of a83ad004b3c5...)

241 views Asked by At

I am using go-git and I would like to print the short hash.

I mean, for example "a83ad00" instead of "a83ad004b3c5971a194ba86b96fe313b94bbcde7".

I looked at the source code of got-git, but could not find a corresponding function.

How to get the short "partial" hash?

1

There are 1 answers

1
shyam On

Couldn't you substring it? I do not see any from the API docs

full := repo.Head().Hash().String()
short := full[0:8]