Skip to content

Instantly share code, notes, and snippets.

@nottrobin
Created June 9, 2022 21:13
Show Gist options
  • Save nottrobin/4356719f2f7f4c6834bdebe5fa7bf327 to your computer and use it in GitHub Desktop.
Save nottrobin/4356719f2f7f4c6834bdebe5fa7bf327 to your computer and use it in GitHub Desktop.
Find latest commit, check for modified articles in it, check if it was added in this commit
#! /usr/bin/env bash
commit_id=$(git log --format="%H" -n 1)
articles=( $(git diff --name-only HEAD HEAD^ | egrep '^_articles') )
for article in "${articles[@]}"
do
article_added_in=$(git log --pretty=format:"%H" --diff-filter=A -- $article)
if [ "$commit_id" = "$article_added_in" ]; then
echo $article
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment