At the command line I can do
git diff --name-only <hashA> <hashB>
to enumerate all the changed files. How would I do this in gitpython?
Here's a technique I found snooping around the source to connect a git hash/sha to a particular gitpython Commit object.
# test_git_diff.py
import git
#remote_repo="https://github.com/jxramos/DataApp--ParamCompare/commits/master"
git_repo = git.Repo( "." )
source_hash = '825faef1097207479f968c6a5353e41612127849'
target_hash = 'HEAD'
source_commit = git_repo.commit( source_hash )
target_commit = git_repo.commit( target_hash )
git_diff = source_commit.diff( target_commit )
changed_files = [ f.b_path for f in git_diff ]
print( "\n".join( changed_files ))
Comparing side by side with shell output
> python test_git_diff.py
Model.py
README.md
data_app.py
param_plotting.py
param_stats.py
session_info.py
static/summary_page_styles.css
templates/data_explore_page.html
templates/embed.html
templates/lin_reg_result.html
templates/plot_page.html
templates/summary_page.html
test/test_data/1.x.csv
test/test_data/1.y.csv
>
>
> git diff --name-only 825faef1097207479f968c6a5353e41612127849 HEAD
Model.py
README.md
data_app.py
param_plotting.py
param_stats.py
session_info.py
static/summary_page_styles.css
templates/data_explore_page.html
templates/embed.html
templates/lin_reg_result.html
templates/plot_page.html
templates/summary_page.html
test/test_data/1.x.csv
test/test_data/1.y.csv