1

This will help to form the release notes. In our release notes, we have to include certain database changes that are related to a specific table, because it affects the usability of the product directly.

These files are only newly added, they are not edited. So in general, they would not have differences. The differences is the whole file.

If we can find the changes on these *.sql file commits, either after a certain commit or since a certain date, it would be nice. From this report, we can browse and separate the ones that has the interested table name.

I am going to be trying with the answers in these posts:

how to show all commited sql files in git from a specific commit on

Get list of files committed on git branch in last month from remote

Community
  • 1
  • 1

1 Answers1

3

Code:

tableName=MY_TABLE

fileMask=\*.sql

threeMonthsAgo=$(date -d"$(date) -3 month" +%s)

targetSHA=$(git rev-list --reverse --since=$threeMonthsAgo HEAD -- "$fileMask"|head -1)

git diff -G$tableName --regexp-ignore-case --name-only $targetSHA HEAD -- "$fileMask"

Breakdown:

git diff [--options] <commit> <commit> [--] [<path>…​]:

This is to view the changes between two arbitrary <commit>.

-G<regex>

Look for differences whose patch text contains added/removed lines that match .

--regexp-ignore-case

Match the regular expression limiting patterns without regard to letter case.

--name-only

Show only names of changed files.

git rev-list [--options] <commit>…​ [--] [<paths>…​]:

List commits that are reachable by following the parent links from the given commits.

The output is given in reverse chronological order by default.

--reverse

Output the commits in reverse order.

--since=<date>

Show commits more recent than a specific date.

srage
  • 990
  • 1
  • 9
  • 27