Dvc: Print shorter versions of git commit hashes in `dvc diff`

Created on 18 Apr 2019  路  6Comments  路  Source: iterative/dvc

Per https://github.com/iterative/dvc.org/pull/244#discussion_r275607398, requested by @shcheklein

Currently dvc diff outputs a line such as

dvc diff from 6a819f8fa053f124f6a5487efc824a8c17366c71 to 612f6caf5c5daeb172167db285efd8b169d41b60

with the full-length commit hashes. Can we just print the first 7 characters like Git and GitHub support?

c3-small-fix p3-nice-to-have ui

All 6 comments

Ping @efiop what do you think? If you approve, I can try to implement this myself and send a PR. Any tips on what source code to focus on will be appreciated if so.

@jorgeorpinel Great idea! All diff-related logic is in dvc/repo/diff.py dvc/command/diff.py and dvc/scm/git/__init__.py pretty much. The part that needs adjusting is most likely in dvc/scm/git/__init__.py::Git::get_diff_trees. Thanks for looking into it :slightly_smiling_face: Let us know if you need any additional help with this patch.

@jorgeorpinel thanks! 馃憤 do you want to assign it to yourself?

Thanks @efiop. I do need some more guidance. Questions:

  • Most importantly: Is there a README on how to install the dvc repo locally for development? I guess just pip install -r requirements.txt but when how do I run that local copy of DVC? To test my changes.
  • Less relevant but I'm curious about: dvc/scm/git/__init__.py::Git::_get_diff_trees has
    python from gitdb.exc import BadObject, BadName
    (which seems to be the only place where gitdb is used in the entire repo?)
    but a) I can't find gitdb in requirements.txt and b) I can't find gitdb.exc in the gitdb API ref. Is the exc module maybe from an older version of gitdb? I'm a bit lost with that one, sorry.

@jorgeorpinel I think this a good starting point to setup dev environment - https://dvc.org/doc/user-guide/contributing

https://github.com/gitpython-developers/GitPython pulls gitdb with it. I'm not sure about the version though.

Thanks Ivan!

I followed the contributing guide which was quite straightforward, thanks. This allowed me to test my small change locally and it seems it works. Here's the PR: https://github.com/iterative/dvc/pull/1906

Regarding gitdb I do see it in the reqs of gitpython now, thanks. And it is a pretty outdated version it seems (0.6.4 while the latest is 2.0.5 atm) But still I can't find the exc module in that old version's API ref. Oh well, don't really need that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

analystanand picture analystanand  路  3Comments

siddygups picture siddygups  路  3Comments

prihoda picture prihoda  路  3Comments

robguinness picture robguinness  路  3Comments

gregfriedland picture gregfriedland  路  3Comments