You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Allow to recover from ENOTINHISTORY with a tag and handle detached head repo
- Tag sha will now be used also if there is a gitHead in last release and it's not in the history
- Use `git merge-base` to determine if a commit is in history, allowing to use CI creating detached head repo
- Mention recovery solution by creating a version tag in `ENOTINHISTORY` and `ENOGITHEAD` error messages
- Do not mention branches containing missing commit in `ENOTINHISTORY` and `ENOGITHEAD` error messages as it's not available by default on most CI
* Retrieve the list of commits on the current branch since the last released version, or all the commits of the current branch if there is no last released version.
15
15
*
16
16
* The commit correspoding to the last released version is determined as follow:
17
-
* - Use `lastRelease.gitHead` is defined and present in `config.options.branch` history.
18
-
* - Search for a tag named `v<version>` or `<version>` and it's associated commit sha if present in `config.options.branch` history.
19
-
*
20
-
* If a commit corresponding to the last released is not found, unshallow the repository (as most CI create a shallow clone with limited number of commits and no tags) and try again.
17
+
* - Use `lastRelease.gitHead` if defined and present in `config.options.branch` history.
18
+
* - If `lastRelease.gitHead` is not in the `config.options.branch` history, unshallow the repository and try again.
19
+
* - If `lastRelease.gitHead` is still not in the `config.options.branch` history, search for a tag named `v<version>` or `<version>` and verify if it's associated commit sha is present in `config.options.branch` history.
21
20
*
22
21
* @param {Object} config
23
22
* @param {Object} config.lastRelease The lastRelease object obtained from the getLastRelease plugin.
return`The commit the last release of this package was derived from is not in the direct history of the "${branch}" branch.
85
-
This means semantic-release can not extract the commits between now and then.
86
-
This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
87
-
You can recover from this error by publishing manually or restoring the commit "${gitHead}".
88
-
89
-
${branches&&branches.length
90
-
? `Here is a list of branches that still contain the commit in question: \n * ${branches.join('\n * ')}`
91
-
: ''}`;
80
+
This means semantic-release can not extract the commits between now and then.
81
+
This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
82
+
83
+
You can recover from this error by restoring the commit "${gitHead}" or by creating a tag for the version "${version}" on the commit corresponding to this release:
84
+
$ git tag -f v${version||'<version>'} <commit sha1 corresponding to last release>
* Get the commit sha for a given version, if it is contained in the given branch.
31
+
* Get the commit sha for a given version, if it's contained in the given branch.
39
32
*
33
+
* @param {string} gitHead The commit sha to look for.
40
34
* @param {string} version The version corresponding to the commit sha to look for. Used to search in git tags.
41
-
* @param {string} branch The branch that must have the commit in its direct history.
42
-
* @param {string} gitHead The commit sha to verify.
43
35
*
44
-
* @return {Promise<string>} A Promise that resolves to `gitHead` if defined and if present in branch direct history or the commit sha corresponding to `version`.
36
+
* @return {Promise<string>} A Promise that resolves to the commit sha of the version, either `gitHead` of the commit associated with the `version` tag.
45
37
*
46
-
* @throws {SemanticReleaseError} with code `ENOTINHISTORY` if `gitHead` or the commit sha dereived from `version` is not in the direct history of `branch`. The Error will have a `branches` attributes with the list of branches containing the commit.
38
+
* @throws {SemanticReleaseError} with code `ENOTINHISTORY` if `gitHead` or the commit sha dereived from `version` is not in the direct history of `branch`.
47
39
* @throws {SemanticReleaseError} with code `ENOGITHEAD` if `gitHead` is undefined and no commit sha can be found for the `version`.
48
40
*/
49
-
module.exports=async(version,branch,gitHead)=>{
50
-
if(!gitHead&&version){
51
-
// Look for the version tag only if no gitHead exists
0 commit comments