fix(git): treat stale rejection as REPOSITORY_CHANGED (#14829)

This commit is contained in:
Rhys Arkins 2022-03-28 17:44:40 +02:00 committed by GitHub
parent 25d793f690
commit 00c74a9ca2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View file

@ -22,7 +22,6 @@ export function checkForPlatformFailure(err: Error): Error | null {
'early EOF',
'fatal: bad config', // .gitmodules problem
'expected flush after ref listing',
'[rejected] (stale info)',
];
for (const errorStr of externalHostFailureStrings) {
if (err.message.includes(errorStr)) {

View file

@ -982,18 +982,25 @@ export async function fetchCommit({
export async function commitFiles(
commitConfig: CommitFilesConfig
): Promise<CommitSha | null> {
const commitResult = await prepareCommit(commitConfig);
if (commitResult) {
const pushResult = await pushCommit(commitConfig);
if (pushResult) {
const { branchName } = commitConfig;
const { commitSha } = commitResult;
config.branchCommits[branchName] = commitSha;
config.branchIsModified[branchName] = false;
return commitSha;
try {
const commitResult = await prepareCommit(commitConfig);
if (commitResult) {
const pushResult = await pushCommit(commitConfig);
if (pushResult) {
const { branchName } = commitConfig;
const { commitSha } = commitResult;
config.branchCommits[branchName] = commitSha;
config.branchIsModified[branchName] = false;
return commitSha;
}
}
return null;
} catch (err) /* istanbul ignore next */ {
if (err.message.includes('[rejected] (stale info)')) {
throw new Error(REPOSITORY_CHANGED);
}
throw err;
}
return null;
}
export function getUrl({