Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements to GitHubReleaseTask #11166

Merged
merged 11 commits into from
Aug 22, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"loc.input.label.tagSource": "Tag source",
"loc.input.help.tagSource": "Specify the tag to be used for release creation. The 'Git tag' option automatically takes the tag which is associated with the Git commit. Use the 'User specified tag' option to manually provide a tag.",
"loc.input.label.tagPattern": "Tag Pattern",
"loc.input.help.tagPattern": "Specify the regex for tag to be used for release creation.",
"loc.input.help.tagPattern": " Specify the git tag pattern using regex(Eg. `release-v1.*`). GitHub release will be created only for commits that have matching git tag. ",
"loc.input.label.tag": "Tag",
"loc.input.help.tag": "Specify the tag for which to create, edit, or delete a release. You can also use a variable here. E.g. `$(myTagName)`.",
"loc.input.label.title": "Release title",
Expand Down Expand Up @@ -66,7 +66,7 @@
"loc.messages.MissingAssetError": "File not found: %s",
"loc.messages.MultipleReleasesFoundError": "Only 1 release was expected but more than 1 release was found for tag: %s. Unable to perform the action.",
"loc.messages.MultipleTagFound": "Only 1 tag was expected but more than 1 tag was found for the given commit: %s. Unable to perform the action.",
"loc.messages.NoTagFound": "Release will not be created as no tags could be found for the target commit. For more details check out the ‘Tag Source’ section in documentation: https://aka.ms/AA4f03a.",
"loc.messages.NoTagFound": "Release will not be created as the tags for the target commit do not match with the given tag pattern.",
"loc.messages.DeleteAllExistingAssets": "Deleting all existing assets...",
"loc.messages.DuplicateAssetFound": "Duplicate asset found: %s",
"loc.messages.AssetsDeletedSuccessfully": "Assets deleted successfully.",
Expand Down
12 changes: 11 additions & 1 deletion Tasks/GitHubReleaseV0/Tests/ChangeLogL0Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class ChangeLogL0Tests {
await this.validateGetChangeLog3();
await this.validateGetChangeLog4();
await this.validateGetChangeLog5();
await this.validateGetChangeLog6();
}

public static async validateGetChangeLog1() {
Expand Down Expand Up @@ -42,9 +43,18 @@ export class ChangeLogL0Tests {
}
}

public static async validateGetChangeLog6(){
let changeLogLabels = `[{"label": "hello", "displayName": "Closed UX Issues/PRs", "state": "CLOSED"}, {"label" : "nope", "displayName": "Open Bugs", "state": "OPEN"}]`;
let changes = await new ChangeLog().getChangeLog("endpoint", "owner/repo", "target", 250, ChangeLogStartCommit.lastFullRelease, "issueBased", null, JSON.parse(changeLogLabels));

if (changes === this.expectedAllIssuesChanges) {
console.log(TestString.noCategoryChangeLog);
}
}

public static readonly expectedCommitBasedChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n* xyz Fixing issue #56. [ #9 ]\n* abc Fixing issue #2 #3. [ #4, #5 ]\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
public static readonly expectedAllIssuesChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n* #1: Incorrect color contrast in control panel\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
public static readonly expectedIssueBasedChanges = "\n\n## Closed UX Issues/PRs:\n\n\n* #1: Incorrect color contrast in control panel\n\n\n## Open Bugs:\n\n\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
public static readonly expectedIssueBasedChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n\n### Closed UX Issues/PRs:\n\n\n* #1: Incorrect color contrast in control panel\n\n### Open Bugs:\n\n\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";

}

Expand Down
1 change: 1 addition & 0 deletions Tasks/GitHubReleaseV0/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('GitHubReleaseTaskTests Suite', function() {
assert(tr.stdout.search(TestString.getChangeLogKeyword) >= 0, 'should have printed: ' + TestString.getChangeLogKeyword);
assert(tr.stdout.search(TestString.allIssuesChangeLog) >= 0, 'should have printed: ' + TestString.allIssuesChangeLog);
assert(tr.stdout.search(TestString.issueBasedChangeLog) >= 0, 'should have printed: ' + TestString.issueBasedChangeLog);
assert(tr.stdout.search(TestString.noCategoryChangeLog) >= 0, 'should have printed: ' + TestString.noCategoryChangeLog);
assert(tr.stdout.search("Tag Name: v1.2") >=0, 'should have printed: TagName: v1.2');
assert(tr.stdout.search("Tag Name: pre_rel") >=0, 'should have printed: TagName: pre_rel');
assert(tr.stdout.search("Tag Name: tagName") >=0, 'should have printed: TagName: tagName');
Expand Down
1 change: 1 addition & 0 deletions Tasks/GitHubReleaseV0/Tests/TestStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export class TestString {
public static readonly tagMatchingKeyword: string = "isTagMatching method should work properly";
public static readonly allIssuesChangeLog: string = "getChangeLog should generate All Issues ChangeLog";
public static readonly issueBasedChangeLog: string = "getChangeLog should generate Issue Based ChangeLog";
public static readonly noCategoryChangeLog: string = "ChangeLog generated should be a flatlist of issues.";
}
28 changes: 16 additions & 12 deletions Tasks/GitHubReleaseV0/operations/ChangeLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,16 @@ export class ChangeLog {
tl.debug("Group wise issues : " + JSON.stringify(groupedIssuesDictionary));
Object.keys(groupedIssuesDictionary).forEach((group: string) => {
if (groupedIssuesDictionary[group].length === 0) return;
let changeLogGroupTitle = util.format(this._changeLogTitleFormat, group);
if (index >= this._changeLogVisibleLimit) {
seeMoreChangeLog = seeMoreChangeLog + changeLogGroupTitle + Delimiters.newLine;
}
else {
topXChangeLog = topXChangeLog + changeLogGroupTitle + Delimiters.newLine;
index++;
//If the only category is the default cateogry, don't add the category title.
TheLayman marked this conversation as resolved.
Show resolved Hide resolved
if (index > 0 || group!= this._defaultGroup){
let changeLogGroupTitle = util.format(this._groupTitleFormat, group);
if (index >= this._changeLogVisibleLimit) {
seeMoreChangeLog = seeMoreChangeLog + changeLogGroupTitle + Delimiters.newLine;
}
else {
topXChangeLog = topXChangeLog + changeLogGroupTitle + Delimiters.newLine;
index++;
}
}
groupedIssuesDictionary[group].forEach(issueDetails => {
let changeLogPerIssue: string = this._getChangeLogPerIssue(issueDetails.id, issueDetails.issue);
Expand All @@ -151,7 +154,7 @@ export class ChangeLog {
}
});
});
changeLog = this._generateChangeLog(topXChangeLog, seeMoreChangeLog, false);
changeLog = this._generateChangeLog(topXChangeLog, seeMoreChangeLog);
console.log(tl.loc("ComputingChangeLogSuccess"));
return changeLog;
}
Expand Down Expand Up @@ -199,7 +202,7 @@ export class ChangeLog {
topXChangeLog = topXChangeLog + changeLogPerIssue + Delimiters.newLine;
}
});
changeLog = this._generateChangeLog(topXChangeLog, seeMoreChangeLog, true);
changeLog = this._generateChangeLog(topXChangeLog, seeMoreChangeLog);
console.log(tl.loc("ComputingChangeLogSuccess"));
return changeLog;
}
Expand Down Expand Up @@ -234,7 +237,7 @@ export class ChangeLog {
topXChangeLog = topXChangeLog + changeLogPerCommit + Delimiters.newLine;
}
});
changeLog = this._generateChangeLog(topXChangeLog, seeMoreChangeLog, true);
changeLog = this._generateChangeLog(topXChangeLog, seeMoreChangeLog);
console.log(tl.loc("ComputingChangeLogSuccess"));
return changeLog;
}
Expand Down Expand Up @@ -644,10 +647,10 @@ export class ChangeLog {
return "";
}

private _generateChangeLog(topXChangeLog: string, seeMoreChangeLog: string, includeDefaultTitle: boolean): string {
private _generateChangeLog(topXChangeLog: string, seeMoreChangeLog: string): string {
let changeLog: string = "";
if (topXChangeLog) {
changeLog = (includeDefaultTitle ? util.format(this._changeLogTitleFormat, this._changeLogTitle) : "") + topXChangeLog;
changeLog = util.format(this._changeLogTitleFormat, this._changeLogTitle) + topXChangeLog;

if(!seeMoreChangeLog) {
changeLog = changeLog + Delimiters.newLine + this._getAutoGeneratedText();
Expand Down Expand Up @@ -691,6 +694,7 @@ export class ChangeLog {
private readonly _defaultGroup: string = tl.loc("DefaultCategory");
private readonly _changeLogVisibleLimit: number = 10;
private readonly _changeLogTitleFormat: string = "\n\n## %s:\n\n";
private readonly _groupTitleFormat: string = "\n### %s:\n\n";
private readonly _buildUrlFormat: string = "%s/%s/_build/results?buildId=%s&view=logs";
private readonly _autoGeneratedTextFormat: string = "This list of changes was [auto generated](%s).";
private readonly _seeMoreChangeLogFormat: string = "<details><summary><b>%s</b></summary>\n\n%s\n%s</details>"; // For showing See more button if more than 10 commits message are to be shown to user.
Expand Down
10 changes: 5 additions & 5 deletions Tasks/GitHubReleaseV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "GitHubRelease",
"friendlyName": "GitHub Release",
"description": "Create, edit, or delete a GitHub release",
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/github-release",
"helpUrl": "https://aka.ms/AA5vv5o",
"helpMarkDown": "[Learn more about this task](https://aka.ms/AA3aeiw)",
"category": "Utility",
"visibility": [
Expand All @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 157,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down Expand Up @@ -89,7 +89,7 @@
"label": "Tag Pattern",
"required": false,
"visibleRule": "tagSource = auto",
"helpMarkDown": "Specify the regex for tag to be used for release creation."
"helpMarkDown": " Specify the git tag pattern using regex(Eg. `release-v1.*`). GitHub release will be created only for commits that have matching git tag. "
},
{
"name": "tag",
Expand Down Expand Up @@ -226,7 +226,7 @@
"type": "radio",
"label": "Changelog type",
"required": true,
"defaultValue": "issueBased",
"defaultValue": "commitBased",
"groupName": "changeLogConfiguration",
"visibleRule": "addChangeLog = true",
"helpMarkDown": "Changelog can be commit based or issue based . Commit based changelog lists all commits included in a release where as Issue based changelog lists all the issues/pr included in the release. ",
Expand Down Expand Up @@ -283,7 +283,7 @@
"MissingAssetError": "File not found: %s",
"MultipleReleasesFoundError": "Only 1 release was expected but more than 1 release was found for tag: %s. Unable to perform the action.",
"MultipleTagFound": "Only 1 tag was expected but more than 1 tag was found for the given commit: %s. Unable to perform the action.",
"NoTagFound": "Release will not be created as no tags could be found for the target commit. For more details check out the ‘Tag Source’ section in documentation: https://aka.ms/AA4f03a.",
"NoTagFound": "Release will not be created as the tags for the target commit do not match with the given tag pattern.",
"DeleteAllExistingAssets": "Deleting all existing assets...",
"DuplicateAssetFound": "Duplicate asset found: %s",
"AssetsDeletedSuccessfully": "Assets deleted successfully.",
Expand Down
6 changes: 3 additions & 3 deletions Tasks/GitHubReleaseV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "GitHubRelease",
"friendlyName": "ms-resource:loc.friendlyName",
"description": "ms-resource:loc.description",
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/github-release",
"helpUrl": "https://aka.ms/AA5vv5o",
"helpMarkDown": "ms-resource:loc.helpMarkDown",
"category": "Utility",
"visibility": [
Expand All @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 157,
"Patch": 0
"Patch": 1
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down Expand Up @@ -225,7 +225,7 @@
"type": "radio",
"label": "ms-resource:loc.input.label.changeLogType",
"required": true,
"defaultValue": "issueBased",
"defaultValue": "commitBased",
"groupName": "changeLogConfiguration",
"visibleRule": "addChangeLog = true",
"helpMarkDown": "ms-resource:loc.input.help.changeLogType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"loc.input.label.tagSource": "Tag source",
"loc.input.help.tagSource": "Specify the tag to be used for release creation. The 'Git tag' option automatically takes the tag which is associated with the Git commit. Use the 'User specified tag' option to manually provide a tag.",
"loc.input.label.tagPattern": "Tag Pattern",
"loc.input.help.tagPattern": "Specify the regex for tag to be used for release creation.",
"loc.input.help.tagPattern": "Specify the git tag pattern using regex(Eg. `release-v1.*`). GitHub release will be created only for commits that have matching git tag. ",
"loc.input.label.tag": "Tag",
"loc.input.help.tag": "Specify the tag for which to create, edit, or delete a release. You can also use a variable here. E.g. `$(myTagName)`.",
"loc.input.label.title": "Release title",
Expand Down Expand Up @@ -66,7 +66,7 @@
"loc.messages.MissingAssetError": "File not found: %s",
"loc.messages.MultipleReleasesFoundError": "Only 1 release was expected but more than 1 release was found for tag: %s. Unable to perform the action.",
"loc.messages.MultipleTagFound": "Only 1 tag was expected but more than 1 tag was found for the given commit: %s. Unable to perform the action.",
"loc.messages.NoTagFound": "Release will not be created as no tags could be found for the target commit. For more details check out the ‘Tag Source’ section in documentation: https://aka.ms/AA4f03a.",
"loc.messages.NoTagFound": "Release will not be created as the tags for the target commit do not match with the given tag pattern",
"loc.messages.DeleteAllExistingAssets": "Deleting all existing assets...",
"loc.messages.DuplicateAssetFound": "Duplicate asset found: %s",
"loc.messages.AssetsDeletedSuccessfully": "Assets deleted successfully.",
Expand Down
12 changes: 11 additions & 1 deletion Tasks/GitHubReleaseV1/Tests/ChangeLogL0Tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class ChangeLogL0Tests {
await this.validateGetChangeLog3();
await this.validateGetChangeLog4();
await this.validateGetChangeLog5();
await this.validateGetChangeLog6();
}

public static async validateGetChangeLog1() {
Expand Down Expand Up @@ -42,9 +43,18 @@ export class ChangeLogL0Tests {
}
}

public static async validateGetChangeLog6(){
let changeLogLabels = `[{"label": "hello", "displayName": "Closed UX Issues/PRs", "state": "CLOSED"}, {"label" : "nope", "displayName": "Open Bugs", "state": "OPEN"}]`;
let changes = await new ChangeLog().getChangeLog("endpoint", "owner/repo", "target", 250, ChangeLogStartCommit.lastFullRelease, "issueBased", null, JSON.parse(changeLogLabels));

if (changes === this.expectedAllIssuesChanges) {
console.log(TestString.noCategoryChangeLog);
}
}

public static readonly expectedCommitBasedChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n* xyz Fixing issue #56. [ #9 ]\n* abc Fixing issue #2 #3. [ #4, #5 ]\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
public static readonly expectedAllIssuesChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n* #1: Incorrect color contrast in control panel\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
public static readonly expectedIssueBasedChanges = "\n\n## Closed UX Issues/PRs:\n\n\n* #1: Incorrect color contrast in control panel\n\n\n## Open Bugs:\n\n\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";
public static readonly expectedIssueBasedChanges = "\n\n## loc_mock_ChangeLogTitle:\n\n\n### Closed UX Issues/PRs:\n\n\n* #1: Incorrect color contrast in control panel\n\n### Open Bugs:\n\n\n* #2: Text alignment confusing in panel\n* #3: Fixed previous minor bugs\n\nThis list of changes was [auto generated](MOCK_RELEASE_URL).";

}

Expand Down
1 change: 1 addition & 0 deletions Tasks/GitHubReleaseV1/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('GitHubReleaseTaskTests Suite', function() {
assert(tr.stdout.search(TestString.getChangeLogKeyword) >= 0, 'should have printed: ' + TestString.getChangeLogKeyword);
assert(tr.stdout.search(TestString.allIssuesChangeLog) >= 0, 'should have printed: ' + TestString.allIssuesChangeLog);
assert(tr.stdout.search(TestString.issueBasedChangeLog) >= 0, 'should have printed: ' + TestString.issueBasedChangeLog);
assert(tr.stdout.search(TestString.noCategoryChangeLog) >= 0, 'should have printed: ' + TestString.noCategoryChangeLog);
assert(tr.stdout.search("Tag Name: v1.2") >=0, 'should have printed: TagName: v1.2');
assert(tr.stdout.search("Tag Name: pre_rel") >=0, 'should have printed: TagName: pre_rel');
assert(tr.stdout.search("Tag Name: tagName") >=0, 'should have printed: TagName: tagName');
Expand Down
1 change: 1 addition & 0 deletions Tasks/GitHubReleaseV1/Tests/TestStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export class TestString {
public static readonly tagMatchingKeyword: string = "isTagMatching method should work properly";
public static readonly allIssuesChangeLog: string = "getChangeLog should generate All Issues ChangeLog";
public static readonly issueBasedChangeLog: string = "getChangeLog should generate Issue Based ChangeLog";
public static readonly noCategoryChangeLog: string = "ChangeLog generated should be a flatlist of issues.";
}
Loading