简体   繁体   中英

Run bash script on every git commit

Out of curiosity, I would like to benchmark a project I have been working on for a while, to see how it's performance at various tasks has varied over time. This project is stored in a git repository.

Fundamentally, it seems like the correct method is

for r in $(git log --pretty="format:%H"); do
    git checkout $r
    echo "$r\t$(./benchmark.sh)" >> results.txt
done

This seems like a hack however (using porcelain for a plumbing task, for starters), and so I am wondering if there is a "preferred" method for this, such as (I wish)

git black_magic-run-on-all ./benchmark.sh > results.txt

It seems like a common enough task, which is why I expect something to exist for this.

对初学者来说,你可以使用rev-list

git rev-list HEAD

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM