fix(release): do not try to overwrite existing git tags

This patch maintains our changesets installation up to date with the change
proposed in https://github.com/atlassian/changesets/pull/569
parent 34a426d6
diff --git a/node_modules/@changesets/cli/dist/cli.cjs.dev.js b/node_modules/@changesets/cli/dist/cli.cjs.dev.js diff --git a/node_modules/@changesets/cli/dist/cli.cjs.dev.js b/node_modules/@changesets/cli/dist/cli.cjs.dev.js
index f771824..197d160 100644 index f771824..9ea7f20 100644
--- a/node_modules/@changesets/cli/dist/cli.cjs.dev.js --- a/node_modules/@changesets/cli/dist/cli.cjs.dev.js
+++ b/node_modules/@changesets/cli/dist/cli.cjs.dev.js +++ b/node_modules/@changesets/cli/dist/cli.cjs.dev.js
@@ -794,7 +794,7 @@ async function publishPackages({ @@ -794,7 +794,7 @@ async function publishPackages({
...@@ -50,3 +50,20 @@ index f771824..197d160 100644 ...@@ -50,3 +50,20 @@ index f771824..197d160 100644
}; };
} }
@@ -940,8 +949,14 @@ async function run(cwd, {
if (tool !== "root") {
for (const pkg of successful) {
const tag = `${pkg.name}@${pkg.newVersion}`;
- logger.log("New tag: ", tag);
- await git.tag(tag, cwd);
+ const isMissingTag = !(await git.tagExists(tag));
+
+ if (isMissingTag) {
+ logger.log("New tag: ", tag);
+ await git.tag(tag, cwd);
+ } else {
+ logger.log("Skipping existing tag: ", tag);
+ }
}
} else {
const tag = `v${successful[0].newVersion}`;
diff --git a/node_modules/@changesets/git/dist/declarations/src/index.d.ts b/node_modules/@changesets/git/dist/declarations/src/index.d.ts
index fbcd2f1..e2d70a3 100644
--- a/node_modules/@changesets/git/dist/declarations/src/index.d.ts
+++ b/node_modules/@changesets/git/dist/declarations/src/index.d.ts
@@ -2,6 +2,7 @@ import { Package } from "@manypkg/get-packages";
declare function add(pathToFile: string, cwd: string): Promise<boolean>;
declare function commit(message: string, cwd: string): Promise<boolean>;
declare function tag(tagStr: string, cwd: string): Promise<boolean>;
+declare function tagExists(tagStr: string): Promise<boolean>;
export declare function getDivergedCommit(cwd: string, ref: string): Promise<string>;
declare const getCommitThatAddsFile: (gitPath: string, cwd: string) => Promise<string | undefined>;
/**
@@ -24,4 +25,4 @@ declare function getChangedPackagesSinceRef({ cwd, ref }: {
cwd: string;
ref: string;
}): Promise<Package[]>;
-export { getCommitThatAddsFile, getCommitsThatAddFiles, getChangedFilesSince, add, commit, tag, getChangedPackagesSinceRef, getChangedChangesetFilesSinceRef };
+export { getCommitThatAddsFile, getCommitsThatAddFiles, getChangedFilesSince, add, commit, tag, tagExists, getChangedPackagesSinceRef, getChangedChangesetFilesSinceRef };
diff --git a/node_modules/@changesets/git/dist/git.cjs.dev.js b/node_modules/@changesets/git/dist/git.cjs.dev.js
index 0564b7e..bd82516 100644
--- a/node_modules/@changesets/git/dist/git.cjs.dev.js
+++ b/node_modules/@changesets/git/dist/git.cjs.dev.js
@@ -46,6 +46,13 @@ async function tag(tagStr, cwd) {
cwd
});
return gitCmd.code === 0;
+}
+
+async function tagExists(tagStr) {
+ const gitCmd = await spawn__default['default']("git", ["tag", "-l", tagStr]);
+ const output = gitCmd.stdout.toString().trim();
+ const tagExists = !!output;
+ return tagExists;
} // Find the commit where we diverged from `ref` at using `git merge-base`
@@ -231,3 +238,4 @@ exports.getCommitThatAddsFile = getCommitThatAddsFile;
exports.getCommitsThatAddFiles = getCommitsThatAddFiles;
exports.getDivergedCommit = getDivergedCommit;
exports.tag = tag;
+exports.tagExists = tagExists;
diff --git a/node_modules/@changesets/git/dist/git.cjs.prod.js b/node_modules/@changesets/git/dist/git.cjs.prod.js
index db3cf82..87ec043 100644
--- a/node_modules/@changesets/git/dist/git.cjs.prod.js
+++ b/node_modules/@changesets/git/dist/git.cjs.prod.js
@@ -35,6 +35,10 @@ async function tag(tagStr, cwd) {
})).code;
}
+async function tagExists(tagStr) {
+ return !!(await spawn__default.default("git", [ "tag", "-l", tagStr ])).stdout.toString().trim();
+}
+
async function getDivergedCommit(cwd, ref) {
const cmd = await spawn__default.default("git", [ "merge-base", ref, "HEAD" ], {
cwd: cwd
@@ -133,4 +137,4 @@ async function getChangedPackagesSinceRef({cwd: cwd, ref: ref}) {
exports.add = add, exports.commit = commit, exports.getChangedChangesetFilesSinceRef = getChangedChangesetFilesSinceRef,
exports.getChangedFilesSince = getChangedFilesSince, exports.getChangedPackagesSinceRef = getChangedPackagesSinceRef,
exports.getCommitThatAddsFile = getCommitThatAddsFile, exports.getCommitsThatAddFiles = getCommitsThatAddFiles,
-exports.getDivergedCommit = getDivergedCommit, exports.tag = tag;
+exports.getDivergedCommit = getDivergedCommit, exports.tag = tag, exports.tagExists = tagExists;
diff --git a/node_modules/@changesets/git/dist/git.esm.js b/node_modules/@changesets/git/dist/git.esm.js
index 9e7349c..922a627 100644
--- a/node_modules/@changesets/git/dist/git.esm.js
+++ b/node_modules/@changesets/git/dist/git.esm.js
@@ -35,6 +35,13 @@ async function tag(tagStr, cwd) {
cwd
});
return gitCmd.code === 0;
+}
+
+async function tagExists(tagStr) {
+ const gitCmd = await spawn("git", ["tag", "-l", tagStr]);
+ const output = gitCmd.stdout.toString().trim();
+ const tagExists = !!output;
+ return tagExists;
} // Find the commit where we diverged from `ref` at using `git merge-base`
@@ -211,4 +218,4 @@ async function getChangedPackagesSinceRef({
.filter((pkg, idx, packages) => packages.indexOf(pkg) === idx);
}
-export { add, commit, getChangedChangesetFilesSinceRef, getChangedFilesSince, getChangedPackagesSinceRef, getCommitThatAddsFile, getCommitsThatAddFiles, getDivergedCommit, tag };
+export { add, commit, getChangedChangesetFilesSinceRef, getChangedFilesSince, getChangedPackagesSinceRef, getCommitThatAddsFile, getCommitsThatAddFiles, getDivergedCommit, tag, tagExists };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment