When working in SVN, I have a batch script I've used in the past to create "DEPLOY" and "RESTORE" folders off of diffs between branches. The script will create a "DEPLOY" folder containing all added and modified files, and a "RESTORE" folder containing all modified files.

The purpose of this, is to deploy a set of files to a different environment. I can just copy the "DEPLOY" folder to any number of servers. If there is a bug that made it through QA, and we need to immediately rollback changes, we can just copy the "RESTORE" folder to all the same servers.

I just wrote a similar script for Git: Git-Diff-Build-Script

While writing that script, I didn't read the Git docs closely enough, and missed the "git diff" --diff-filter parameter. Because of this, I thought I would have to use AWK to sanitize my list of files, but then I read about the --diff-filter parameter, and changed 2 lines of code to 1:


info="$(git diff origin/prod origin/dev --name-status)"
files="$(echo "$info" | awk '$1 ~/M|A/ {print $2}')"

USING diff-filter:

files="$(git diff origin/prod origin/dev --name-only --diff-filter=MA)"
Tagged with: AntAWKBashShellGitSVN