Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jordihm9/5ca24df0096b6d038a04782b1dc6d072 to your computer and use it in GitHub Desktop.

Select an option

Save jordihm9/5ca24df0096b6d038a04782b1dc6d072 to your computer and use it in GitHub Desktop.
Add an empty line at the end of every file changed in every merge commit from the current branch compared to the main branch of the repository
#!/usr/bin/env bash
commit_hashes=$(git log --merges origin/$(git_main_branch)..${git_current_branch} --format="%H")
for commit_hash in ${commit_hashes}; do
files=$(git show ${commit_hash} --name-only --pretty=format: | sort | uniq | grep -E '\.(ts|tsx|js|jsx)$')
for file in ${files}; do
if [[ -e $file ]]; then
echo "Processing ${file}"
echo "" >> $file
else
echo "[SKIP] $file"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment