Skip to content

Commit 75cc990

Browse files
committed
Merge branch 'pr118' into develop
* pr118: (GH-119) Corrected casing check (GH-120) Corrected parts identification updated documentation Implemented the access token option
2 parents f94fb00 + e2cbcb8 commit 75cc990

File tree

11 files changed

+142
-83
lines changed

11 files changed

+142
-83
lines changed

Source/GitReleaseManager.Cli/Options/BaseGitHubSubOptions.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ namespace GitReleaseManager.Cli.Options
1010

1111
public abstract class BaseGitHubSubOptions : BaseSubOptions
1212
{
13-
[Option('u', "username", HelpText = "The username to access GitHub with.", Required = true)]
13+
[Option('u', "username", HelpText = "The username to access GitHub with.", Required = true, SetName = "Basic Auth")]
1414
public string UserName { get; set; }
1515

16-
[Option('p', "password", HelpText = "The password to access GitHub with.", Required = true)]
16+
[Option('p', "password", HelpText = "The password to access GitHub with.", Required = true, SetName = "Basic Auth")]
1717
public string Password { get; set; }
1818

19+
[Option("token", HelpText = "The Access Token to access GitHub with.", Required = true, SetName = "OAuth flow")]
20+
public string Token { get; set; }
21+
1922
[Option('o', "owner", HelpText = "The owner of the repository.", Required = true)]
2023
public string RepositoryOwner { get; set; }
2124

@@ -24,7 +27,10 @@ public abstract class BaseGitHubSubOptions : BaseSubOptions
2427

2528
public GitHubClient CreateGitHubClient()
2629
{
27-
var credentials = new Credentials(this.UserName, this.Password);
30+
var credentials = string.IsNullOrWhiteSpace(Token)
31+
? new Credentials(UserName, Password)
32+
: new Credentials(Token);
33+
2834
var github = new GitHubClient(new ProductHeaderValue("GitReleaseManager")) { Credentials = credentials };
2935
return github;
3036
}

Source/GitReleaseManager.Cli/Program.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ private static int Main(string[] args)
3636
var fileSystem = new FileSystem();
3737

3838
return Parser.Default.ParseArguments<CreateSubOptions, AddAssetSubOptions, CloseSubOptions, PublishSubOptions, ExportSubOptions, InitSubOptions, ShowConfigSubOptions>(args)
39-
.MapResult(
40-
(CreateSubOptions opts) => CreateReleaseAsync(opts, fileSystem).Result,
41-
(AddAssetSubOptions opts) => AddAssetsAsync(opts).Result,
42-
(CloseSubOptions opts) => CloseMilestoneAsync(opts).Result,
43-
(PublishSubOptions opts) => PublishReleaseAsync(opts).Result,
44-
(ExportSubOptions opts) => ExportReleasesAsync(opts, fileSystem).Result,
45-
(InitSubOptions opts) => CreateSampleConfigFile(opts, fileSystem),
46-
(ShowConfigSubOptions opts) => ShowConfig(opts, fileSystem),
47-
errs => 1);
39+
.MapResult(
40+
(CreateSubOptions opts) => CreateReleaseAsync(opts, fileSystem).Result,
41+
(AddAssetSubOptions opts) => AddAssetsAsync(opts).Result,
42+
(CloseSubOptions opts) => CloseMilestoneAsync(opts).Result,
43+
(PublishSubOptions opts) => PublishReleaseAsync(opts).Result,
44+
(ExportSubOptions opts) => ExportReleasesAsync(opts, fileSystem).Result,
45+
(InitSubOptions opts) => CreateSampleConfigFile(opts, fileSystem),
46+
(ShowConfigSubOptions opts) => ShowConfig(opts, fileSystem),
47+
errs => 1);
4848
}
4949

5050
private static async Task<int> CreateReleaseAsync(CreateSubOptions subOptions, IFileSystem fileSystem)

Source/GitReleaseManager/OctokitExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public static async Task<IEnumerable<Issue>> AllIssuesForMilestone(this GitHubCl
3838
State = ItemStateFilter.Open
3939
};
4040
var parts = milestone.Url.Split('/');
41-
var user = parts[2];
42-
var repository = parts[3];
41+
var user = parts[4];
42+
var repository = parts[5];
4343
var closedIssues = await gitHubClient.Issue.GetAllForRepository(user, repository, closedIssueRequest);
4444
var openIssues = await gitHubClient.Issue.GetAllForRepository(user, repository, openIssueRequest);
4545
return openIssues.Union(closedIssues);

Source/GitReleaseManager/ReleaseNotesBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public async Task<string> BuildReleaseNotes()
8585

8686
private void Append(IEnumerable<Issue> issues, string label, StringBuilder stringBuilder)
8787
{
88-
var features = issues.Where(x => x.Labels.Any(l => l.Name == label)).ToList();
88+
var features = issues.Where(x => x.Labels.Any(l => l.Name.ToUpperInvariant() == label.ToUpperInvariant())).ToList();
8989

9090
if (features.Count > 0)
9191
{

docs/commands/add-assets.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
Once a draft set of release notes has been created, it is possible to add additional assets to the release using the addasset command.
44

55
## **Required Parameters**
6-
* `-u, -username`: The username to access GitHub with.
7-
* `-p, -password`: The password to access GitHub with.
8-
* `-o, -owner`: The owner of the repository.
9-
* `-r, -repository`: The name of the repository.
10-
* `-t, -tagName`: The name of the release (Typically this is the generated SemVer Version Number).
11-
* `-a, -assets`: Path(s) to the file(s) to include in the release. This is a comma separated list of files to include
6+
7+
* `-u, --username`: The username to access GitHub with.
8+
* `-p, --password`: The password to access GitHub with.
9+
* `--token`: The access token to access GitHub with.
10+
* `-o, --owner`: The owner of the repository.
11+
* `-r, --repository`: The name of the repository.
12+
* `-t, --tagName`: The name of the release (Typically this is the generated SemVer Version Number).
13+
* `-a, --assets`: Path(s) to the file(s) to include in the release. This is a comma separated list of files to include
1214

1315
## **Optional Parameters**
14-
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
15-
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
16+
17+
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
18+
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
19+
20+
## **Notes**
21+
22+
For Authentication use either username and password, or token parameter
1623

1724
## **Examples**
1825

19-
```
26+
```bash
2027
gitreleasemanager.exe addasset -t 0.1.0 -u bob -p password -o repoOwner -r repo -a c:\buildartifacts\setup.exe,c:\buildartifacts\setup.nupkg
2128

22-
gitreleasemanager.exe create -tagName 0.1.0 -username bob -password password -owner repoOwner -repository repo -assets c:\buildartifacts\setup.exe,c:\buildartifacts\setup.nupkg
29+
gitreleasemanager.exe create --tagName 0.1.0 --username bob --password password --owner repoOwner --repository repo --assets c:\buildartifacts\setup.exe,c:\buildartifacts\setup.nupkg
30+
31+
gitreleasemanager.exe create --tagName 0.1.0 --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo --assets c:\buildartifacts\setup.exe,c:\buildartifacts\setup.nupkg
2332
```

docs/commands/close.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@
33
Out of the box, publishing a release on GitHub does not close the milestone associated with the release. This command, when executed, closes the specified milestone.
44

55
## **Required Parameters**
6-
* `-u, -username`: The username to access GitHub with.
7-
* `-p, -password`: The password to access GitHub with.
8-
* `-o, -owner`: The owner of the repository.
9-
* `-r, -repository`: The name of the repository.
10-
* `-m, -milestone`: The milestone to use.
6+
7+
* `-u, --username`: The username to access GitHub with.
8+
* `-p, --password`: The password to access GitHub with.
9+
* `--token`: The access token to access GitHub with.
10+
* `-o, --owner`: The owner of the repository.
11+
* `-r, --repository`: The name of the repository.
12+
* `-m, --milestone`: The milestone to use.
1113

1214
## **Optional Parameters**
13-
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
14-
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
1515

16-
## **Examples**
16+
* `-d, --targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
17+
* `-l, --logFilePath`: Path to where log file should be created. Defaults to logging to console.
18+
19+
## **Notes**
20+
21+
For Authentication use either username and password, or token parameter
1722

18-
```
23+
## **Examples**
24+
25+
```bash
1926
gitreleasemanager.exe close -m 0.1.0 -u bob -p password -o repoOwner -r repo
2027

21-
gitreleasemanager.exe close -milestone 0.1.0 -username bob -password password -owner repoOwner -repository repo
28+
gitreleasemanager.exe close --milestone 0.1.0 --username bob --password password --owner repoOwner --repository repo
29+
30+
gitreleasemanager.exe close --milestone 0.1.0 --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo
2231
```

docs/commands/create.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,46 @@ This is the main command of GitReleaseManager and it is used to create a draft s
55
There are two modes of operation when creating a Release. GitReleaseManager can take as an input the name of the milestone to generate the release notes from. Or, it can take as an input the name of a file which contains the release notes to include in the Release.
66

77
## **Required Parameters**
8-
* `-u, -username`: The username to access GitHub with.
9-
* `-p, -password`: The password to access GitHub with.
10-
* `-o, -owner`: The owner of the repository.
11-
* `-r, -repository`: The name of the repository.
8+
9+
* `-u, --username`: The username to access GitHub with.
10+
* `-p, --password`: The password to access GitHub with.
11+
* `--token`: The access token to access GitHub with.
12+
* `-o, --owner`: The owner of the repository.
13+
* `-r, --repository`: The name of the repository.
1214

1315
## **Optional Parameters**
14-
* `-m, -milestone`: The milestone to use.
15-
* `-n, -name`: The name of the release (Typically this is the generated SemVer Version Number).
16-
* `-i, -inputFilePath`: The path to the file to be used as the content of the release notes.
17-
* `-e, -pre`: Creates the release as a pre-release.
18-
* `-a, -assets`: Path(s) to the file(s) to include in the release. This is a comma separated list of files to include
19-
* `-c, -targetcommitish`: The commit to tag. Can be a branch or SHA. Defaults to repository's default branch.
20-
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
21-
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
2216

23-
## **Examples**
17+
* `-m, --milestone`: The milestone to use.
18+
* `-n, --name`: The name of the release (Typically this is the generated SemVer Version Number).
19+
* `-i, --inputFilePath`: The path to the file to be used as the content of the release notes.
20+
* `-e, --pre`: Creates the release as a pre-release.
21+
* `-a, --assets`: Path(s) to the file(s) to include in the release. This is a comma separated list of files to include
22+
* `-c, --targetcommitish`: The commit to tag. Can be a branch or SHA. Defaults to repository's default branch.
23+
* `-d, --targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
24+
* `-l, --logFilePath`: Path to where log file should be created. Defaults to logging to console.
25+
26+
## **Notes**
27+
28+
For Authentication use either username and password, or token parameter
29+
30+
## **Examples**
2431

2532
Use GitReleaseManager to create a Release, generating the release notes based on Milestone:
2633

27-
```
34+
```bash
2835
gitreleasemanager.exe create -m 0.1.0 -u bob -p password -o repoOwner -r repo
2936

30-
gitreleasemanager.exe create -milestone 0.1.0 -username bob -password password -owner repoOwner -repository repo
37+
gitreleasemanager.exe create --milestone 0.1.0 --username bob --password password --owner repoOwner --repository repo
38+
39+
gitreleasemanager.exe create --milestone 0.1.0 --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo
3140
```
3241

3342
Use GitReleaseManager to create a Release, taking the release notes as an input parameter:
3443

35-
```
44+
```bash
3645
gitreleasemanager.exe create -i c:\temp\releasenotes.md -n 0.1.0 -u bob -p password -o repoOwner -r repo
3746

38-
gitreleasemanager.exe create -inputFilePath c:\temp\releasenotes.md -name 0.1.0 -username bob -password password -owner repoOwner -repository repo
47+
gitreleasemanager.exe create --inputFilePath c:\temp\releasenotes.md --name 0.1.0 --username bob --password password --owner repoOwner --repository repo
48+
49+
gitreleasemanager.exe create --inputFilePath c:\temp\releasenotes.md --name 0.1.0 --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo
3950
```

docs/commands/export.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,32 @@ This command will export all the release notes for a given repository on GitHub.
55
There are two modes of operation when exporting Release Notes. GitReleaseManager can either export all Release Notes, or can export only a specific Release, using the tagName parameter.
66

77
## **Required Parameters**
8-
* `-u, -username`: The username to access GitHub with.
9-
* `-p, -password`: The password to access GitHub with.
10-
* `-o, -owner`: The owner of the repository.
11-
* `-r, -repository`: The name of the repository.
12-
* `-f, -fileOutputPath`: Path to the file export releases.
8+
9+
* `-u, --username`: The username to access GitHub with.
10+
* `-p, --password`: The password to access GitHub with.
11+
* `--token`: The access token to access GitHub with.
12+
* `-o, --owner`: The owner of the repository.
13+
* `-r, --repository`: The name of the repository.
14+
* `-f, --fileOutputPath`: Path to the file export releases.
1315

1416
## **Optional Parameters**
15-
* `-t, -tagName`: The name of the release (Typically this is the generated SemVer Version Number).
16-
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
17-
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
17+
18+
* `-t, --tagName`: The name of the release (Typically this is the generated SemVer Version Number).
19+
* `-d, --targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
20+
* `-l, --logFilePath`: Path to where log file should be created. Defaults to logging to console.
21+
22+
## **Notes**
23+
24+
For Authentication use either username and password, or token parameter
1825

1926
## **Examples**
2027

2128
Use GitReleaseManager to export all Release Notes:
2229

23-
```
30+
```bash
2431
gitreleasemanager.exe export -u bob -p password -o repoOwner -r repo -f c:\temp\releases.md
2532

26-
gitreleasemanager.exe export -username bob -password password -owner repoOwner -repository repo -fileOutputPath c:\temp\releases.md
33+
gitreleasemanager.exe export --username bob --password password --owner repoOwner --repository repo --fileOutputPath c:\temp\releases.md
34+
35+
gitreleasemanager.exe export --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo --fileOutputPath c:\temp\releases.md
2736
```

docs/commands/init.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
The Init command is used to create GitReleaseManager.yaml which controls the configurable options of GitReleaseManager
44

55
## **Optional Parameters**
6-
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
7-
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
86

9-
## **Examples**
7+
* `-d, --targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
8+
* `-l, --logFilePath`: Path to where log file should be created. Defaults to logging to console.
9+
10+
## **Notes**
11+
12+
For Authentication use either username and password, or token parameter
13+
14+
## **Examples**
1015

1116
Create a new GitReleaseManager.yaml file in the current working directory:
1217

13-
```
18+
```bash
1419
gitreleasemanager.exe init
1520
```
1621

1722
Create a new GitReleaseManager.yaml file in a specific directory:
1823

19-
```
24+
```bash
2025
gitreleasemanager.exe init -d c:\temp
2126

22-
gitreleasemanager.exe init -targetDirectory c:\temp
27+
gitreleasemanager.exe init --targetDirectory c:\temp
2328
```

docs/commands/publish.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@
33
While it would be possible to automatically publish a set of release notes in a single command, it is envisioned that some manual intervention is required to ensure that all release notes are valid, and any additional information is added to the release, prior to publishing. As a result, a second command is required to actually publish a release.
44

55
## **Required Parameters**
6-
* `-u, -username`: The username to access GitHub with.
7-
* `-p, -password`: The password to access GitHub with.
8-
* `-o, -owner`: The owner of the repository.
9-
* `-r, -repository`: The name of the repository.
10-
* `-t, -tagName`: The name of the release (Typically this is the generated SemVer Version Number).
6+
7+
* `-u, --username`: The username to access GitHub with.
8+
* `-p, --password`: The password to access GitHub with.
9+
* `--token`: The access token to access GitHub with.
10+
* `-o, --owner`: The owner of the repository.
11+
* `-r, --repository`: The name of the repository.
12+
* `-t, --tagName`: The name of the release (Typically this is the generated SemVer Version Number).
1113

1214
## **Optional Parameters**
13-
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
14-
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
1515

16-
## **Examples**
16+
* `-d, -targetDirectory`: The directory on which GitReleaseManager should be executed. Defaults to current directory.
17+
* `-l, -logFilePath`: Path to where log file should be created. Defaults to logging to console.
18+
19+
## **Notes**
20+
21+
For Authentication use either username and password, or token parameter
1722

18-
```
23+
## **Examples**
24+
25+
```bash
1926
gitreleasemanager.exe publish -t 0.1.0 -u bob -p password -o repoOwner -r repo
2027

21-
gitreleasemanager.exe publish -tagName 0.1.0 -username bob -password password -owner repoOwner -repository repo
28+
gitreleasemanager.exe publish --tagName 0.1.0 --username bob --password password --owner repoOwner --repository repo
29+
30+
gitreleasemanager.exe publish --tagName 0.1.0 --token fsdfsf67657sdf5s7d5f --owner repoOwner --repository repo
2231
```

0 commit comments

Comments
 (0)