Git - Handle tag conflict during pull operation (#167278)

Handle tag conflict during pull operation
This commit is contained in:
Ladislau Szomoru
2022-11-25 18:05:22 +01:00
committed by GitHub
parent a05f15f5c8
commit d4a299631a
3 changed files with 74 additions and 4 deletions

View File

@@ -1764,6 +1764,25 @@ export class Repository {
}
}
async fetchTags(options: { remote: string; tags: string[]; force?: boolean }): Promise<void> {
const args = ['fetch'];
const spawnOptions: SpawnOptions = {
env: { 'GIT_HTTP_USER_AGENT': this.git.userAgent }
};
args.push(options.remote);
for (const tag of options.tags) {
args.push(`refs/tags/${tag}:refs/tags/${tag}`);
}
if (options.force) {
args.push('--force');
}
await this.exec(args, spawnOptions);
}
async pull(rebase?: boolean, remote?: string, branch?: string, options: PullOptions = {}): Promise<void> {
const args = ['pull'];
@@ -1803,6 +1822,8 @@ export class Repository {
err.gitErrorCode = GitErrorCodes.CantLockRef;
} else if (/cannot rebase onto multiple branches/i.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.CantRebaseMultipleBranches;
} else if (/! \[rejected\].*\(would clobber existing tag\)/m.test(err.stderr || '')) {
err.gitErrorCode = GitErrorCodes.TagConflict;
}
throw err;