-
Notifications
You must be signed in to change notification settings - Fork 247
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
Automation Script: find_moved_or_renamed_commit #1559
Open
Derrick2000
wants to merge
4
commits into
TestingResearchIllinois:main
Choose a base branch
from
Derrick2000:auto-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
auto-find-moved-or-renamed/find_moved_or_renamed_commit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# This script identifies the commit where a specified function was modified, | ||
# starting from a given commit, and handles cases where the function or file | ||
# might have been renamed or moved. | ||
|
||
# Usage: | ||
# ./find_moved_or_renamed_commit.sh <FUNCTION_NAME> <FILENAME> <START_COMMIT> | ||
|
||
# Parameters: | ||
FUNCTION_NAME="$1" | ||
FILENAME="$2" # Relative Path | ||
START_COMMIT="$3" | ||
|
||
if [ -z "$FUNCTION_NAME" ] || [ -z "$FILENAME" ] || [ -z "$START_COMMIT" ]; then | ||
echo "Usage: $0 <FUNCTION_NAME> <FILENAME> <START_COMMIT>" | ||
exit 1 | ||
fi | ||
|
||
# Ensure we're in the root directory of the repository | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
METHOD_REGEX="(public|protected|private|static|\s)+\s+.*\s+$FUNCTION_NAME\s*\(.*\)" | ||
|
||
echo "Checking for function renames or file renames/moves..." | ||
|
||
# Track file renames: See commits where the file was renamed. | ||
# Track function changes: See commits where the function was modified, or removed. | ||
git log "$START_COMMIT"..HEAD \ | ||
--follow \ | ||
--find-renames \ | ||
-G"$METHOD_REGEX" \ | ||
-p \ | ||
--name-status \ | ||
--reverse \ | ||
--color \ | ||
--decorate \ | ||
-- "$FILENAME" | less -R | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Overview | ||
This automation script is designed to identify the specific commit that moved or renamed a test function or test file from the ones recorded in the IDOFT repository. | ||
|
||
# Instructions | ||
1. Copy and paste `find_moved_or_renamed_commit.sh` to the Repo you are working on. | ||
2. `git checkout xxx` (replace xxx with the commit hash that the flake test was detected in IDOFT) | ||
3. Find and copy the **Relative Path** of the given testing file, it should contain the given FUNCTION_NAME. (Paste it somewhere, this is the FILENAME that will be used later) | ||
4. `git checkout master` (or whichever branch you want that has the latest commit) | ||
5. Execute the script by running: | ||
|
||
``` bash | ||
chmod +x find_moved_or_renamed_commit.sh` | ||
./find_moved_or_renamed_commit.sh <FUNCTION_NAME> <FILENAME> <START_COMMIT> | ||
``` | ||
|
||
## Examples | ||
|
||
### A Row in IDOFT | ||
``` | ||
https://github.com/apache/ignite-3,a1aa7fd4e2398c72827777ec5417d67915ff4da3,modules/configuration,org.apache.ignite.internal.configuration.asm.ConfigurationAsmGeneratorTest.testConstructInternalConfig,ID,MovedOrRenamed,,https://github.com/apache/ignite-3/commit/b48ddcba7cd2bd3b9a053ae131c25b44a0400e27 | ||
``` | ||
|
||
### Execute | ||
``` | ||
./find_moved_or_renamed_commit.sh testConstructInternalConfig modules/configuration/src/test/java/org/apache/ignite/internal/configuration/asm/ConfigurationAsmGeneratorTest.java a1aa7fd4e2398c72827777ec5417d67915ff4da3 | ||
``` | ||
|
||
### Output | ||
``` | ||
commit b48ddcba7cd2bd3b9a053ae131c25b44a0400e27 | ||
Author: Aleksandr Pakhomov <[email protected]> | ||
Date: Wed Apr 26 20:02:34 2023 +0400 | ||
|
||
IGNITE-19152 Use schema information in LocalFileConfigurationStorage (#1988) | ||
|
||
--------- | ||
|
||
Co-authored-by: Ivan Bessonov <[email protected]> | ||
|
||
D modules/configuration/src/test/java/org/apache/ignite/internal/configuration/asm/ConfigurationAsmGeneratorTest.java | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script is not automatically quit after showing the output. Maybe try
-- "$FILENAME" | cat
instead ofless -R
, or directly output the console to an outputfile