Skip to content

Commit

Permalink
feat(changelog): add commit links in changelog markdown
Browse files Browse the repository at this point in the history
only implemented for github and only availble for new artifacts
  • Loading branch information
azlam-abdulsalam committed Jan 17, 2024
1 parent c63c1db commit b06123f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,23 @@ export default class ChangelogMarkdownGenerator {
let tableOfCommits = [['Date', 'Time', 'Commit ID', 'Commit Message']];
for (let commit of artifact.commits) {
let commitDate: Date = new Date(commit.date);
let specificCommitURL: string;
if (artifact.repoUrl != null) {
if(artifact.repoUrl.startsWith("git"))
{
specificCommitURL=""; //no http url available
}
else if (artifact.repoUrl.includes("github.com")) {
let repoUrl = artifact.repoUrl.split('.git')[0];
specificCommitURL = `${repoUrl}/commit/${commit.commitId}`;
} else {
specificCommitURL=""; //other git providers are not supported
}
}
tableOfCommits.push([
this.getDate(commitDate),
this.getTime(commitDate),
commit.commitId,
artifact.repoUrl?`[${commit.commitId}](${specificCommitURL})`:commit.commitId,
commit.message,
]);
}
Expand Down
5 changes: 5 additions & 0 deletions packages/sfp-cli/src/impl/changelog/ReleaseChangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export interface Artifact extends Changelog {
*/
latestCommitId: string;

/**
* Repository URL where the artifact was generated
*/
repoUrl: string;

/**
* Commits between previous artifact's package changelog and current artifact's package changelog
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default class ReleaseChangelogUpdater {
from: undefined,
to: sfpPackage.sourceVersion?.slice(0, 8),
version: sfpPackage.package_version_number,
repoUrl: sfpPackage.repository_url,
latestCommitId: undefined,
commits: undefined,
};
Expand Down

0 comments on commit b06123f

Please sign in to comment.