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

"Variable FILES is empty." if one renames the data/... file #3167

Open
probonopd opened this issue Jun 18, 2023 · 9 comments
Open

"Variable FILES is empty." if one renames the data/... file #3167

probonopd opened this issue Jun 18, 2023 · 9 comments

Comments

@probonopd
Copy link
Member

"Variable FILES is empty." if one renames the data/... file.
It seems like our detection of which file was changed doesn't handle renames properly.

Example: #3141

@probonopd
Copy link
Member Author

We've been using

FILES=$(git log -1 -p data/ | grep +++ | cut -d '/' -f 2-| sed -e 's|dev/null||g')

How do we need to change this so that renames are also caught?

Would this be a good approach?

FILES=$(git diff --name-status -1 --diff-filter=AR -- data/ | awk '{print $2}')

@probonopd
Copy link
Member Author

Maybe better:

# Most recent addition or renaming within the last 10 commits
FILES=$(git log -10 --name-status --diff-filter=AR --pretty=format: -- data/ | awk '/^A/ || /^R/ {file=$2} END {print file}')

@probonopd
Copy link
Member Author

No... the last one finds wrong files in PRs...

@probonopd
Copy link
Member Author

probonopd commented Jun 18, 2023

Argh. These tend to find the wrong files in PRs.

E.g., e8a0914 in #3122 tested a file unrelated to the PR.

Why? Reverting for now.

@probonopd probonopd reopened this Jun 18, 2023
@probonopd
Copy link
Member Author

Maybe @andy5995 has an idea?

@probonopd probonopd pinned this issue Jun 18, 2023
@probonopd
Copy link
Member Author

Maybe related to #2595

@andy5995
Copy link
Contributor

Maybe add --follow to the git log command?

--follow
Continue listing the history of a file beyond renames (works only for a single file).

@andy5995
Copy link
Contributor

Also available with git log:

-M[<n>], --find-renames[=<n>]
           If generating diffs, detect and report renames for each commit. For following files
           across renames while traversing history, see --follow. If n is specified, it is a
           threshold on the similarity index (i.e. amount of addition/deletions compared to the
           file’s size). For example, -M90% means Git should consider a delete/add pair to be a
           rename if more than 90% of the file hasn’t changed. Without a % sign, the number is to
           be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is
           thus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to
           exact renames, use -M100%. The default similarity index is 50%.

and

       --summary
           Output a condensed summary of extended header information such as creations, renames and mode changes.

and this one it looks like you've already tried

       --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
           Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type
           (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had
           their pairing Broken (B). Any combination of the filter characters (including none) can be used. When *
           (All-or-none) is added to the combination, all paths are selected if there is any file that matches other
           criteria in the comparison; if there is no file that matches other criteria, nothing is selected.

@probonopd
Copy link
Member Author

probonopd commented Jul 15, 2023

Maybe we need to touch renamed files.

If someone knows a better solution, please let me know.

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

No branches or pull requests

2 participants