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', 'early EOF',
'fatal: bad config', // .gitmodules problem 'fatal: bad config', // .gitmodules problem
'expected flush after ref listing', 'expected flush after ref listing',
'[rejected] (stale info)',
]; ];
for (const errorStr of externalHostFailureStrings) { for (const errorStr of externalHostFailureStrings) {
if (err.message.includes(errorStr)) { if (err.message.includes(errorStr)) {

View file

@ -982,18 +982,25 @@ export async function fetchCommit({
export async function commitFiles( export async function commitFiles(
commitConfig: CommitFilesConfig commitConfig: CommitFilesConfig
): Promise<CommitSha | null> { ): Promise<CommitSha | null> {
const commitResult = await prepareCommit(commitConfig); try {
if (commitResult) { const commitResult = await prepareCommit(commitConfig);
const pushResult = await pushCommit(commitConfig); if (commitResult) {
if (pushResult) { const pushResult = await pushCommit(commitConfig);
const { branchName } = commitConfig; if (pushResult) {
const { commitSha } = commitResult; const { branchName } = commitConfig;
config.branchCommits[branchName] = commitSha; const { commitSha } = commitResult;
config.branchIsModified[branchName] = false; config.branchCommits[branchName] = commitSha;
return 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({ export function getUrl({