Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/lib/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const LABEL_CONFIG = [
{ name: "bug", title: "Fixed bugs" }
];

exports.generateChangeLogContent = async ({ releaseDate, issues, mergeRequests }, options = {}) => {
exports.generateChangeLogContent = async ({ releaseDate, issues, mergeRequests, compare }, options = {}) => {
// Separate by labels
let changelogBucket = exports._createLabelBucket();

Expand Down Expand Up @@ -52,6 +52,9 @@ exports.generateChangeLogContent = async ({ releaseDate, issues, mergeRequests }
}
}
}
if (!_.isEmpty(compare)) {
changelogContent += `\n[${compare.text}](${compare.url})\n`;
}
return changelogContent;
}
};
Expand Down
10 changes: 10 additions & 0 deletions app/lib/compare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Gitlab = require("../adapters/gitlab");

exports.getCompareForLatestAndSecondLatestTag = async (projectId, latestTag, secondLatestTag) => {
const repository = await Gitlab.getRepoByProjectId(projectId);

return {
text: `List of commits ${secondLatestTag.name}...${latestTag.name}`,
url: `${repository.web_url}/compare/${secondLatestTag.name}...${latestTag.name}`,
};
};
4 changes: 3 additions & 1 deletion app/lib/generator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require("lodash");
const CompareLib = require("./compare");
const IssueLib = require("./issue");
const MergeRequestLib = require("./mergeRequest");
const TagLib = require("./tag");
Expand All @@ -25,8 +26,9 @@ exports.generate = async () => {
Logger.debug(`New End Date: ${endDate}`);
}

const compare = await CompareLib.getCompareForLatestAndSecondLatestTag(Env.GITLAB_PROJECT_ID, latestTag, secondLatestTag);
const changeLog = await ChangelogLib.getChangelogByStartAndEndDate(startDate, endDate);
const changeLogContent = await ChangelogLib.generateChangeLogContent(changeLog, {useSlack: false});
const changeLogContent = await ChangelogLib.generateChangeLogContent({...changeLog, compare}, {useSlack: false});
Logger.debug(`Changelog: ${changeLogContent}`);
return await TagLib.upsertTagDescriptionByProjectIdAndTag(Env.GITLAB_PROJECT_ID, latestTag, changeLogContent);
};