diff --git a/doc/submit.md b/doc/submit.md
index 2450fa07..945307ce 100644
--- a/doc/submit.md
+++ b/doc/submit.md
@@ -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/).
diff --git a/doc/update.md b/doc/update.md
index 3d3787d7..ac601bd9 100644
--- a/doc/update.md
+++ b/doc/update.md
@@ -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. |
diff --git a/src/WingetCreateCLI/Commands/BaseCommand.cs b/src/WingetCreateCLI/Commands/BaseCommand.cs
index 39b59b7d..820602ce 100644
--- a/src/WingetCreateCLI/Commands/BaseCommand.cs
+++ b/src/WingetCreateCLI/Commands/BaseCommand.cs
@@ -69,6 +69,11 @@ public abstract class BaseCommand
/// Gets or sets the most recent pull request id associated with the command.
///
public int PullRequestNumber { get; set; }
+
+ ///
+ /// Gets or sets the title for the pull request.
+ ///
+ public virtual string PRTitle { get; set; }
///
/// Gets or sets a value indicating whether or not to submit the PR via a fork. Should be true when submitting as a user, false when submitting as an app.
@@ -578,7 +583,40 @@ protected async Task GitHubSubmitManifests(Manifests manifests, string prT
}
return true;
- }
+ }
+
+ ///
+ /// Returns the title to be used for the pull request.
+ ///
+ /// Manifest object containing metadata of new manifest to be submitted.
+ /// Manifest object representing an already exisitng manifest in the repository.
+ /// A string representing the pull request title.
+ protected string GetPRTitle(Manifests currentManifest, Manifests repositoryManifest = null)
+ {
+ // Use custom PR title if provided by the user.
+ if (!string.IsNullOrEmpty(this.PRTitle))
+ {
+ return this.PRTitle;
+ }
+
+ string packageId = currentManifest.VersionManifest != null ? currentManifest.VersionManifest.PackageIdentifier : currentManifest.SingletonManifest.PackageIdentifier;
+ string currentVersion = currentManifest.VersionManifest != null ? currentManifest.VersionManifest.PackageVersion : currentManifest.SingletonManifest.PackageVersion;
+
+ // If no manifest exists in the repository, this is a new package.
+ if (repositoryManifest == null)
+ {
+ return $"New package: {packageId} version {currentVersion}";
+ }
+
+ string repositoryVersion = repositoryManifest.VersionManifest != null ? repositoryManifest.VersionManifest.PackageVersion : repositoryManifest.SingletonManifest.PackageVersion;
+
+ return WinGetUtil.CompareVersions(currentVersion, repositoryVersion) switch
+ {
+ > 0 => $"New version: {packageId} version {currentVersion}",
+ < 0 => $"Add version: {packageId} version {currentVersion}",
+ _ => $"Update version: {packageId} version {currentVersion}",
+ };
+ }
///
/// Removes fields with empty string values from a given object.
diff --git a/src/WingetCreateCLI/Commands/NewCommand.cs b/src/WingetCreateCLI/Commands/NewCommand.cs
index d8ed5578..ff37e787 100644
--- a/src/WingetCreateCLI/Commands/NewCommand.cs
+++ b/src/WingetCreateCLI/Commands/NewCommand.cs
@@ -250,7 +250,9 @@ public override async Task Execute()
{
if (await this.LoadGitHubClient(true))
{
- return commandEvent.IsSuccessful = await this.GitHubSubmitManifests(manifests);
+ return commandEvent.IsSuccessful = await this.GitHubSubmitManifests(
+ manifests,
+ this.GetPRTitle(manifests));
}
return false;
diff --git a/src/WingetCreateCLI/Commands/SubmitCommand.cs b/src/WingetCreateCLI/Commands/SubmitCommand.cs
index a26c88c7..9d7bbd84 100644
--- a/src/WingetCreateCLI/Commands/SubmitCommand.cs
+++ b/src/WingetCreateCLI/Commands/SubmitCommand.cs
@@ -53,7 +53,7 @@ public static IEnumerable Examples
/// Gets or sets the title for the pull request.
///
[Option('p', "prtitle", Required = false, HelpText = "PullRequestTitle_HelpText", ResourceType = typeof(Resources))]
- public string PRTitle { get; set; }
+ public override string PRTitle { get => base.PRTitle; set => base.PRTitle = value; }
///
/// Gets or sets the unbound arguments that exist after the first positional parameter.
diff --git a/src/WingetCreateCLI/Commands/UpdateCommand.cs b/src/WingetCreateCLI/Commands/UpdateCommand.cs
index 9f788f16..82bf4069 100644
--- a/src/WingetCreateCLI/Commands/UpdateCommand.cs
+++ b/src/WingetCreateCLI/Commands/UpdateCommand.cs
@@ -70,7 +70,7 @@ public static IEnumerable Examples
/// Gets or sets the title for the pull request.
///
[Option('p', "prtitle", Required = false, HelpText = "PullRequestTitle_HelpText", ResourceType = typeof(Resources))]
- public string PRTitle { get; set; }
+ public override string PRTitle { get => base.PRTitle; set => base.PRTitle = value; }
///
/// Gets or sets a value indicating whether or not the updated manifest should be submitted to Github.
@@ -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(updatedManifests, originalManifests)))
: false;
}
diff --git a/src/WingetCreateCLI/Properties/Resources.Designer.cs b/src/WingetCreateCLI/Properties/Resources.Designer.cs
index 5a45cd10..89820273 100644
--- a/src/WingetCreateCLI/Properties/Resources.Designer.cs
+++ b/src/WingetCreateCLI/Properties/Resources.Designer.cs
@@ -1881,7 +1881,7 @@ public static string PublisherUrl_KeywordDescription {
}
///
- /// Looks up a localized string similar to The title of the pull request submitted to GitHub. Default is "{PackageId} version {Version}".
+ /// Looks up a localized string similar to The title of the pull request submitted to GitHub.
///
public static string PullRequestTitle_HelpText {
get {
diff --git a/src/WingetCreateCLI/Properties/Resources.resx b/src/WingetCreateCLI/Properties/Resources.resx
index 85cc85d5..33ed2559 100644
--- a/src/WingetCreateCLI/Properties/Resources.resx
+++ b/src/WingetCreateCLI/Properties/Resources.resx
@@ -358,7 +358,7 @@
The publisher name |e.g. Microsoft|
- The title of the pull request submitted to GitHub. Default is "{PackageId} version {Version}"
+ The title of the pull request submitted to GitHub.
Pull request can be found here: {0}
diff --git a/src/WingetCreateCore/Common/GitHub.cs b/src/WingetCreateCore/Common/GitHub.cs
index 0d176892..8de47173 100644
--- a/src/WingetCreateCore/Common/GitHub.cs
+++ b/src/WingetCreateCore/Common/GitHub.cs
@@ -299,7 +299,7 @@ private async Task 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))