-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow bad dates, but only for imports and only when it's specifically…
… requested In general, it's better if customers rewrite their repos to remove the bad dates because bad dates aren't guaranteed to work with all of our systems and APIs. But, sometimes there are bad dates in a corner of a repo where they're unlikely to cause problems, and the cost of rewriting the repo is too high to be worth it.
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,14 @@ committer Spokes Receive Pack <[email protected]> 1234567890 +0000 | |
This commit object intentionally broken | ||
` | ||
|
||
var suiteDir string = func() string { | ||
pwd, err := os.Getwd() | ||
if err != nil { | ||
panic(err) | ||
} | ||
return pwd | ||
}() | ||
|
||
type SpokesReceivePackTestSuite struct { | ||
suite.Suite | ||
localRepo, remoteRepo string | ||
|
@@ -181,6 +189,28 @@ func (suite *SpokesReceivePackTestSuite) TestSpokesReceivePackHiddenRefs() { | |
"should partially fail") | ||
} | ||
|
||
func (suite *SpokesReceivePackTestSuite) TestBadDate() { | ||
cmd := exec.Command("git", "-C", filepath.Join(suiteDir, "testdata/bad-date/sha1.git"), | ||
"push", "--receive-pack=spokes-receive-pack-wrapper", suite.remoteRepo, "main") | ||
out, err := cmd.CombinedOutput() | ||
suite.T().Logf("$ git %s\n%s", strings.Join(cmd.Args, " "), out) | ||
assert.Error(suite.T(), err, "expect an error a repo with a malformed committer line in a commit") | ||
assert.Contains(suite.T(), string(out), " badDate:", "should complain about a bad date") | ||
} | ||
|
||
func (suite *SpokesReceivePackTestSuite) TestBadDateAllowedWithOverride() { | ||
cmd := exec.Command("git", "-C", filepath.Join(suiteDir, "testdata/bad-date/sha1.git"), | ||
"push", "--receive-pack=spokes-receive-pack-wrapper", suite.remoteRepo, "main") | ||
cmd.Env = append(os.Environ(), | ||
"GIT_SOCKSTAT_VAR_is_importing=bool:true", | ||
"GIT_SOCKSTAT_VAR_allow_baddate_in_import=bool:true", | ||
) | ||
out, err := cmd.CombinedOutput() | ||
suite.T().Logf("$ git %s\n%s", strings.Join(cmd.Args, " "), out) | ||
assert.NoError(suite.T(), err, "expect the push to succeed") | ||
assert.Contains(suite.T(), string(out), " badDate:", "should still complain about a bad date") | ||
} | ||
|
||
func (suite *SpokesReceivePackTestSuite) TestWithGovernor() { | ||
started := make(chan any) | ||
govSock, msgs, cleanup := startFakeGovernor(suite.T(), started, nil) | ||
|
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