Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all files changed between git commits #3

Open
martindsouza opened this issue Jun 3, 2020 · 2 comments
Open

List all files changed between git commits #3

martindsouza opened this issue Jun 3, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@martindsouza
Copy link
Contributor

Currently the build script will autocomplete a section in the _release.sql file. This script scrapes all the packages, views, and triggers and injects them into the release file.

@vincentmorneau had a good idea. Instead of listing all the files, only list files that have changed. This can reduce overall release time if the project has a lot objects or can be very helpful for small patch releases (think one or two file changes). Developers wouldn't need to track what they worked on.

This can be done fairly easily using git diff --name-only <src> <compare> where <src> is the source branch and <compare> is the compare to branch. In this case "branch" can be master, a tag, or a branch.

Ex: git diff --name-only master 0.2.0 will list all the files that have changed since in master since tag 0.2.0. Stackoverflow source.

@vitodcampanelli
Copy link

vitodcampanelli commented Aug 21, 2020

This might be useful is you only wanted to see the files changed in a specific directory (views, packages)

git diff --name-only <src> <compare> <directory>

git diff --name-only master 0.0.1 views

https://riptutorial.com/git/example/4340/show-differences-for-a-specific-file-or-directory

It also might be possible to get the latest tag matching a certain pattern using:

git describe --tags --abbrev=0 --match release-*

Without pattern matching:

git describe --tags --abbrev=0

@vitodcampanelli
Copy link

Pseudo code that might help with the development of this issue.

#!/bin/bash

# current development tag
CURRENT_TAG="master"

# pattern to match for git tags
MATCH_PATTERN="release-*"

# used to get the latest tag using the above pattern
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match $MATCH_PATTERN)

# hard coded value just for test
FILE="all_views.sql"
# which directroy to check
DIR_CHECK="../views"

# output variables to screen to see
echo "Current tag: " $CURRENT_TAG
echo "Previous tag: " $PREVIOUS_TAG

# execute command and output to file
# Use--diff-filter to include on the files you need listed
# A = Added / M = Modified / R = Renamed
echo $(git diff --diff-filter=AMR --name-only $PREVIOUS_TAG $CURRENT_TAG $DIR_CHECK > $FILE)  

# prefix each line with view directory
# there may be a better way other than using sed
sed -i "s\views\@$DIR_CHECK\g" $FILE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants