- if only a single tag is available resolve the initial commit as fallback. this is meant to support initial release scenarios
- FIX https://github.com/mikepenz/release-changelog-builder-action/issues/276
This commit is contained in:
+34
-16
@@ -250,6 +250,16 @@ class GitCommandManager {
|
||||
return output.stdout.trim();
|
||||
});
|
||||
}
|
||||
initialCommit() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const revListOutput = yield this.execGit([
|
||||
'rev-list',
|
||||
'--max-parents=0',
|
||||
'HEAD'
|
||||
]);
|
||||
return revListOutput.stdout.trim();
|
||||
});
|
||||
}
|
||||
static createCommandManager(workingDirectory) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const result = new GitCommandManager();
|
||||
@@ -812,7 +822,7 @@ class ReleaseNotesBuilder {
|
||||
core.startGroup(`🔖 Resolve previous tag`);
|
||||
core.debug(`fromTag undefined, trying to resolve via API`);
|
||||
const tagsApi = new tags_1.Tags(octokit);
|
||||
const previousTag = yield tagsApi.findPredecessorTag(this.owner, this.repo, this.toTag, this.ignorePreReleases, this.configuration.max_tags_to_fetch ||
|
||||
const previousTag = yield tagsApi.findPredecessorTag(this.repositoryPath, this.owner, this.repo, this.toTag, this.ignorePreReleases, this.configuration.max_tags_to_fetch ||
|
||||
configuration_1.DefaultConfiguration.max_tags_to_fetch, this.configuration.tag_resolver || configuration_1.DefaultConfiguration.tag_resolver);
|
||||
if (previousTag == null) {
|
||||
utils_1.failOrError(`💥 Unable to retrieve previous tag given ${this.toTag}`, this.failOnError);
|
||||
@@ -888,6 +898,7 @@ exports.sortTags = exports.Tags = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const semver_1 = __nccwpck_require__(1383);
|
||||
const gitHelper_1 = __nccwpck_require__(353);
|
||||
class Tags {
|
||||
constructor(octokit) {
|
||||
this.octokit = octokit;
|
||||
@@ -929,31 +940,38 @@ class Tags {
|
||||
return tagsInfo;
|
||||
});
|
||||
}
|
||||
findPredecessorTag(owner, repo, tag, ignorePreReleases, maxTagsToFetch, tagResolver) {
|
||||
findPredecessorTag(repositoryPath, owner, repo, tag, ignorePreReleases, maxTagsToFetch, tagResolver) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const tags = sortTags(yield this.getTags(owner, repo, maxTagsToFetch), tagResolver);
|
||||
try {
|
||||
const length = tags.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (tags[i].name.toLocaleLowerCase() === tag.toLocaleLowerCase()) {
|
||||
if (ignorePreReleases) {
|
||||
core.info(`ℹ️ Enabled 'ignorePreReleases', searching for the closest release`);
|
||||
for (let ii = i + 1; ii < length; ii++) {
|
||||
if (!tags[ii].name.includes('-')) {
|
||||
return tags[ii];
|
||||
if (tags.length > 1) {
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (tags[i].name.toLocaleLowerCase() === tag.toLocaleLowerCase()) {
|
||||
if (ignorePreReleases) {
|
||||
core.info(`ℹ️ Enabled 'ignorePreReleases', searching for the closest release`);
|
||||
for (let ii = i + 1; ii < length; ii++) {
|
||||
if (!tags[ii].name.includes('-')) {
|
||||
return tags[ii];
|
||||
}
|
||||
}
|
||||
}
|
||||
return tags[i + 1];
|
||||
}
|
||||
return tags[i + 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
core.info(`ℹ️ Only one tag found for the given repository. Usually this is the case for the initial release.`);
|
||||
// if not specified try to retrieve tag from git
|
||||
const gitHelper = yield gitHelper_1.createCommandManager(repositoryPath);
|
||||
const initialCommit = yield gitHelper.initialCommit();
|
||||
core.info(`🔖 Resolved initial commit (${initialCommit}) from 'git rev-list --max-parents=0 HEAD'`);
|
||||
return { name: 'initial', commit: initialCommit };
|
||||
}
|
||||
return tags[0];
|
||||
}
|
||||
catch (error) {
|
||||
if (tags.length < 1) {
|
||||
core.warning(`⚠️ Only one tag found for the given repository`);
|
||||
}
|
||||
else if (tags.length < 0) {
|
||||
if (tags.length <= 0) {
|
||||
core.warning(`⚠️ No tag found for the given repository`);
|
||||
}
|
||||
return null;
|
||||
@@ -6142,7 +6160,7 @@ const Endpoints = {
|
||||
}
|
||||
};
|
||||
|
||||
const VERSION = "5.3.1";
|
||||
const VERSION = "5.3.7";
|
||||
|
||||
function endpointsToMethods(octokit, endpointsMap) {
|
||||
const newMethods = {};
|
||||
@@ -6527,7 +6545,7 @@ var pluginRequestLog = __nccwpck_require__(8883);
|
||||
var pluginPaginateRest = __nccwpck_require__(4193);
|
||||
var pluginRestEndpointMethods = __nccwpck_require__(3044);
|
||||
|
||||
const VERSION = "18.6.0";
|
||||
const VERSION = "18.6.6";
|
||||
|
||||
const Octokit = core.Octokit.plugin(pluginRequestLog.requestLog, pluginRestEndpointMethods.legacyRestEndpointMethods, pluginPaginateRest.paginateRest).defaults({
|
||||
userAgent: `octokit-rest.js/${VERSION}`
|
||||
|
||||
Reference in New Issue
Block a user