Skip to content

Commit 75fd379

Browse files
Allow control over PR auto-open behavior (#574)
Co-authored-by: AmirMS <104940545+AmelBawa-msft@users.noreply.github.com>
1 parent 737fca6 commit 75fd379

File tree

20 files changed

+175
-15
lines changed

20 files changed

+175
-15
lines changed

doc/new-locale.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ The following arguments are available:
2727
| **-l, --locale** | The package locale to create a new manifest for. If not provided, the tool will prompt you for this value.
2828
| **-r, --reference-locale** | Existing locale manifest to be used as reference for default values. If not provided, the default locale manifest will be used.
2929
| **-o, --out** | The output directory where the newly created manifests will be saved locally.
30-
| **-f,--format** | Output format of the manifest. Default is "yaml". |
31-
| **-t,--token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
30+
| **-f, --format** | Output format of the manifest. Default is "yaml". |
31+
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
32+
| **-n, --no-open** | Boolean value that controls whether the pull request should not be open in the browser on submission. Default is false, meaning the PR will be opened in the browser. |
3233
| **-?, --help** | Gets additional help on this command |
3334

3435
Instructions on setting up GitHub Token for Winget-Create can be found [here](../README.md#github-personal-access-token-classic-permissions).

doc/new.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ The following arguments are available:
2626

2727
| Argument | Description |
2828
|--------------|-------------|
29-
| **-o,--out** | The output directory where the newly created manifests will be saved locally |
29+
| **-o, --out** | The output directory where the newly created manifests will be saved locally |
3030
| **--allow-unsecure-downloads** | Allow unsecure downloads (HTTP) for this operation. |
31-
| **-f,--format** | Output format of the manifest. Default is "yaml". |
32-
| **-t,--token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
31+
| **-f, --format** | Output format of the manifest. Default is "yaml". |
32+
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
33+
| **-n, --no-open** | Boolean value that controls whether the pull request should not be open in the browser on submission. Default is false, meaning the PR will be opened in the browser. |
3334
| **-?, --help** | Gets additional help on this command |
3435

3536
## Winget-Create New Command flow

doc/settings.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,31 @@ The `anonymizePaths` setting controls whether the paths of files and directories
7474
"anonymizePaths": true
7575
}
7676
```
77+
78+
## Manifest
79+
80+
The `Manifest` settings control the behavior of the Winget-Create CLI when creating a manifest.
81+
82+
### format
83+
84+
The `format` setting specifies the format of the manifest file that will be created. By default, this is set to `yaml`. The other supported format is `json`. The `--format` argument provided inline with the command will take precedence over this setting.
85+
86+
```json
87+
"Manifest": {
88+
"format": "yaml"
89+
}
90+
```
91+
92+
## PullRequest
93+
94+
The `PullRequest` settings control the behavior of the Winget-Create CLI when creating a pull request on the Windows Package Manager repository.
95+
96+
### openInBrowser
97+
98+
```json
99+
"PullRequest": {
100+
"openInBrowser": false
101+
},
102+
```
103+
104+
If set to false, the `PullRequest.openInBrowser` setting will prevent the Winget-Create CLI from opening the pull request in the default browser after creating it. By default, this is set to true. The `--no-open` argument provided inline with the command will take precedence over this setting.

doc/submit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The following arguments are available:
1818
| **-p, --prtitle** | The title of the pull request submitted to GitHub.
1919
| **-r, --replace** | Boolean value for replacing an existing manifest from the Windows Package Manager repo. Optionally provide a version or else the latest version will be replaced. Default is false.
2020
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. If no token is provided, tool will prompt for GitHub login credentials. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
21+
| **-n, --no-open** | Boolean value that controls whether the pull request should not be open in the browser on submission. Default is false, meaning the PR will be opened in the browser. |
2122
| **-?, --help** | Gets additional help on this command. |
2223

2324
If you have provided your [GitHub token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) on the command line with the **submit** command and the device is registered with GitHub, **Winget-Create** will submit your PR to [Windows Package Manager repo](https://docs.microsoft.com/windows/package-manager/).

doc/update-locale.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ The following arguments are available:
2626
| **-v, --version** | The version of the package to update the locale for. Default is the latest version.
2727
| **-l, --locale** | The package locale to update the manifest for. If not provided, the tool will prompt you a list of existing locales to choose from.
2828
| **-o, --out** | The output directory where the newly created manifests will be saved locally.
29-
| **-f,--format** | Output format of the manifest. Default is "yaml". |
30-
| **-t,--token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
29+
| **-f, --format** | Output format of the manifest. Default is "yaml". |
30+
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
31+
| **-n, --no-open** | Boolean value that controls whether the pull request should not be open in the browser on submission. Default is false, meaning the PR will be opened in the browser. |
3132
| **-?, --help** | Gets additional help on this command |
3233

3334
Instructions on setting up GitHub Token for Winget-Create can be found [here](../README.md#github-personal-access-token-classic-permissions).

doc/update.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ The following arguments are available:
118118
| **-s, --submit** | Boolean value for submitting to the Windows Package Manager repo. If true, updated manifest will be submitted directly using the provided GitHub Token |
119119
| **-r, --replace** | Boolean value for replacing an existing manifest from the Windows Package Manager repo. Optionally provide a version or else the latest version will be replaced. Default is false. |
120120
| **-i, --interactive** | Boolean value for making the update command interactive. If true, the tool will prompt the user for input. Default is false. |
121-
| **-f,--format** | Output format of the manifest. Default is "yaml". |
121+
| **-f, --format** | Output format of the manifest. Default is "yaml". |
122122
| **--allow-unsecure-downloads** | Allow unsecure downloads (HTTP) for this operation. |
123123
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. If no token is provided, tool will prompt for GitHub login credentials. <br/>⚠️ _Using this argument may result in the token being logged. Consider an alternative approach https://aka.ms/winget-create-token._ |
124+
| **-n, --no-open** | Boolean value that controls whether the pull request should not be open in the browser on submission. Default is false, meaning the PR will be opened in the browser. |
124125
| **-?, --help** | Gets additional help on this command. |
125126

126127
## Submit

src/WingetCreateCLI/Commands/BaseCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public abstract class BaseCommand
104104
/// <summary>
105105
/// Gets or sets a value indicating whether or not to automatically open the PR webpage in the browser after creation.
106106
/// </summary>
107-
public bool OpenPRInBrowser { get; set; } = true;
107+
public bool OpenPRInBrowser { get; set; } = UserSettings.OpenPRInBrowser;
108108

109109
/// <summary>
110110
/// Gets the GitHubClient instance to use for interacting with GitHub from the CLI.
@@ -765,7 +765,7 @@ protected async Task<bool> GitHubSubmitManifests(Manifests manifests, string prT
765765

766766
try
767767
{
768-
PullRequest pullRequest = await this.GitHubClient.SubmitPullRequestAsync(manifests, this.SubmitPRToFork, prTitle, shouldReplace, replaceVersion);
768+
Octokit.PullRequest pullRequest = await this.GitHubClient.SubmitPullRequestAsync(manifests, this.SubmitPRToFork, prTitle, shouldReplace, replaceVersion);
769769
this.PullRequestNumber = pullRequest.Number;
770770
PullRequestEvent pullRequestEvent = new PullRequestEvent { IsSuccessful = true, PullRequestNumber = pullRequest.Number };
771771
TelemetryManager.Log.WriteEvent(pullRequestEvent);

src/WingetCreateCLI/Commands/NewCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public static IEnumerable<Example> Examples
9292
[Option('t', "token", Required = false, HelpText = "GitHubToken_HelpText", ResourceType = typeof(Resources))]
9393
public override string GitHubToken { get => base.GitHubToken; set => base.GitHubToken = value; }
9494

95+
/// <summary>
96+
/// Gets or sets a value indicating whether the PR should be opened automatically in the browser.
97+
/// </summary>
98+
[Option('n', "no-open", Required = false, HelpText = "NoOpenPRInBrowser_HelpText", ResourceType = typeof(Resources))]
99+
public bool NoOpenPRInBrowser { get => !this.OpenPRInBrowser; set => this.OpenPRInBrowser = !value; }
100+
95101
/// <summary>
96102
/// Executes the new command flow.
97103
/// </summary>

src/WingetCreateCLI/Commands/NewLocaleCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ public static IEnumerable<Example> Examples
9898
[Option('t', "token", Required = false, HelpText = "GitHubToken_HelpText", ResourceType = typeof(Resources))]
9999
public override string GitHubToken { get => base.GitHubToken; set => base.GitHubToken = value; }
100100

101+
/// <summary>
102+
/// Gets or sets a value indicating whether the PR should be opened automatically in the browser.
103+
/// </summary>
104+
[Option('n', "no-open", Required = false, HelpText = "NoOpenPRInBrowser_HelpText", ResourceType = typeof(Resources))]
105+
public bool NoOpenPRInBrowser { get => !this.OpenPRInBrowser; set => this.OpenPRInBrowser = !value; }
106+
101107
/// <summary>
102108
/// Executes the new-locale command flow.
103109
/// </summary>

src/WingetCreateCLI/Commands/SubmitCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public static IEnumerable<Example> Examples
6767
[Option('t', "token", Required = false, HelpText = "GitHubToken_HelpText", ResourceType = typeof(Resources))]
6868
public override string GitHubToken { get => base.GitHubToken; set => base.GitHubToken = value; }
6969

70+
/// <summary>
71+
/// Gets or sets a value indicating whether the PR should be opened automatically in the browser.
72+
/// </summary>
73+
[Option('n', "no-open", Required = false, HelpText = "NoOpenPRInBrowser_HelpText", ResourceType = typeof(Resources))]
74+
public bool NoOpenPRInBrowser { get => !this.OpenPRInBrowser; set => this.OpenPRInBrowser = !value; }
75+
7076
/// <summary>
7177
/// Gets or sets the unbound arguments that exist after the first positional parameter.
7278
/// </summary>

0 commit comments

Comments
 (0)