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

Use common pull request titles #388

Merged
merged 5 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion doc/submit.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The following arguments are available:

| Argument | Description |
|--------------|-------------|
| **-p, --prtitle** | The title of the pull request submitted to GitHub. Default is "{PackageId} version {Version}"
| **-p, --prtitle** | The title of the pull request submitted to GitHub.
| **-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.

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/).
Expand Down
2 changes: 1 addition & 1 deletion doc/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The following arguments are available:
| **-v, --version** | Version to be used when updating the package version field.
| **-o, --out** | The output directory where the newly created manifests will be saved locally
| **-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
| **-p, --prtitle** | The title of the pull request submitted to GitHub. Default is "{PackageId} version {Version}"
| **-p, --prtitle** | The title of the pull request submitted to GitHub.
| **-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.
| **-?, --help** | Gets additional help on this command. |

Expand Down
4 changes: 3 additions & 1 deletion src/WingetCreateCLI/Commands/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ public override async Task<bool> Execute()
{
if (await this.LoadGitHubClient(true))
{
return commandEvent.IsSuccessful = await this.GitHubSubmitManifests(manifests);
return commandEvent.IsSuccessful = await this.GitHubSubmitManifests(
manifests,
$"New package: {manifests.InstallerManifest.PackageIdentifier} version {manifests.InstallerManifest.PackageVersion}");
mdanish-kh marked this conversation as resolved.
Show resolved Hide resolved
mdanish-kh marked this conversation as resolved.
Show resolved Hide resolved
}

return false;
Expand Down
23 changes: 22 additions & 1 deletion src/WingetCreateCLI/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ await this.UpdateManifestsInteractively(initialManifests) :
}

return await this.LoadGitHubClient(true)
? (commandEvent.IsSuccessful = await this.GitHubSubmitManifests(updatedManifests, this.PRTitle))
? (commandEvent.IsSuccessful = await this.GitHubSubmitManifests(
updatedManifests,
this.GetPRTitle(originalManifests)))
: false;
}

Expand Down Expand Up @@ -735,5 +737,24 @@ private async Task UpdateSingleInstallerInteractively(Installer installer)
Console.ReadKey();
Console.Clear();
}

private string GetPRTitle(Manifests repositoryManifest)
{
// Use custom PR title if provided by the user.
if (!string.IsNullOrEmpty(this.PRTitle))
{
return this.PRTitle;
}

// Handle case where manifest is still using singleton format
string repositoryVersion = repositoryManifest.SingletonManifest != null ? repositoryManifest.SingletonManifest.PackageVersion : repositoryManifest.InstallerManifest.PackageVersion;

return WinGetUtil.CompareVersions(this.Version, repositoryVersion) switch
{
> 0 => $"New version: {this.Id} version {this.Version}",
< 0 => $"Add version: {this.Id} version {this.Version}",
_ => $"Update version: {this.Id} version {this.Version}",
};
}
mdanish-kh marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
<value>The publisher name |e.g. Microsoft|</value>
</data>
<data name="PullRequestTitle_HelpText" xml:space="preserve">
<value>The title of the pull request submitted to GitHub. Default is "{PackageId} version {Version}"</value>
<value>The title of the pull request submitted to GitHub.</value>
</data>
<data name="PullRequestURI_Message" xml:space="preserve">
<value>Pull request can be found here: {0}</value>
Expand Down
2 changes: 1 addition & 1 deletion src/WingetCreateCore/Common/GitHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private async Task<PullRequest> SubmitPRAsync(string packageId, string version,
repo = await this.github.Repository.Get(this.wingetRepoOwner, this.wingetRepo);
}

string newBranchName = $"autogenerated/{packageId}/{Guid.NewGuid()}";
string newBranchName = $"{packageId}-{version}-{Guid.NewGuid()}";
string newBranchNameHeads = $"heads/{newBranchName}";

if (string.IsNullOrEmpty(prTitle))
Expand Down