[Skratchdot.]

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:

USING AWK:

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

USING diff-filter:

1
files="$(git diff origin/prod origin/dev --name-only --diff-filter=MA)"

Tagged with:


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">