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: Retrieve version gitHead from git tags and unshallow the repo if necessary
Add several fixes and improvements in the identification of the last release gitHead:
- If there is no last release, unshallow the repo in order to retrieve all existing commits
- If git head is not present in last release, try to retrieve it from git tag with format ‘v\<version\>’ or ‘\<version\>’
- If the last release git head cannot be determined and found in commit history, unshallow the repo and try again
- Throw a ENOGITHEAD error if the gitHead for the last release cannot be found in the npm metadata nor in the git tags, preventing to make release based on the all the commits in the repo as before
- Add integration test for the scenario with a packed repo from which `npm republish` fails to read the git head
Fixsemantic-release#447, Fixsemantic-release#393, Fixsemantic-release#280, Fixsemantic-release#276
* 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
+
*
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.
21
+
*
22
+
* @param {Object} config
23
+
* @param {Object} config.lastRelease The lastRelease object obtained from the getLastRelease plugin.
24
+
* @param {string} [config.lastRelease.version] The version number of the last release.
25
+
* @param {string} [config.lastRelease.gitHead] The commit sha used to make the last release.
26
+
* @param {Object} config.options The semantic-relese options.
27
+
* @param {string} config.options.branch The branch to release from.
28
+
*
29
+
* @return {Promise<Array<Commit>>} The list of commits on the branch `config.options.branch` since the last release.
30
+
*
31
+
* @throws {SemanticReleaseError} with code `ENOTINHISTORY` if `config.lastRelease.gitHead` or the commit sha derived from `config.lastRelease.version` is not in the direct history of `config.options.branch`.
32
+
* @throws {SemanticReleaseError} with code `ENOGITHEAD` if `config.lastRelease.gitHead` is undefined and no commit sha can be found for the `config.lastRelease.version`.
* Get the commit sha for a given version, if it is contained in the given branch.
39
+
*
40
+
* @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
+
*
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`.
45
+
*
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.
47
+
* @throws {SemanticReleaseError} with code `ENOGITHEAD` if `gitHead` is undefined and no commit sha can be found for the `version`.
48
+
*/
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