-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: avoid re-generating logictest files if unnecessary
Beforehand, running `dev testlogic` would always run all tests regardless if they were modified, which wastes time. This PR will check to see if logic test folders were modified and only re-generates them if they are modified. It also introduces a new flag, `--force-gen`, which will force generate the logic tests. Fixes: #94845 Release note: None
- Loading branch information
Liam Gillies
committed
Sep 18, 2023
1 parent
defdd31
commit 9e653ae
Showing
3 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -249,3 +249,27 @@ func (d *dev) warnAboutChangeInStressBehavior(timeout time.Duration) { | |
log.Printf("Set DEV_I_UNDERSTAND_ABOUT_STRESS=1 to squelch this message") | ||
} | ||
} | ||
|
||
// This function retrieves the merge-base hash between the current branch and master | ||
func (d *dev) getMergeBaseHash(ctx context.Context) (string, error) { | ||
// List files changed against `master` | ||
remotes, err := d.exec.CommandContextSilent(ctx, "git", "remote", "-v") | ||
if err != nil { | ||
return "", err | ||
} | ||
var upstream string | ||
for _, remote := range strings.Split(strings.TrimSpace(string(remotes)), "\n") { | ||
if (strings.Contains(remote, "github.com/cockroachdb/cockroach") || strings.Contains(remote, "github.com:cockroachdb/cockroach")) && strings.HasSuffix(remote, "(fetch)") { | ||
upstream = strings.Fields(remote)[0] | ||
break | ||
} | ||
} | ||
if upstream == "" { | ||
return "", fmt.Errorf("could not find git upstream, run `git remote add upstream [email protected]:cockroachdb/cockroach.git`") | ||
} | ||
baseBytes, err := d.exec.CommandContextSilent(ctx, "git", "merge-base", fmt.Sprintf("%s/master", upstream), "HEAD") | ||
if err != nil { | ||
return "", err | ||
} | ||
return strings.TrimSpace(string(baseBytes)), nil | ||
} |