From e0425e1d004d5b5cc0fefa1f54419ab4bbfa759f Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 6 Mar 2025 07:33:23 -0700 Subject: [PATCH 1/7] Reverted GitVersion.xml --- GitVersion.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/GitVersion.yml b/GitVersion.yml index 9b976f1c5..78d807140 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,9 +1,10 @@ -workflow: GitFlow/v1 +mode: ContinuousDeployment tag-prefix: '[vV]' +continuous-delivery-fallback-tag: dev branches: develop: mode: ContinuousDeployment - label: develop + tag: develop regex: v2_develop tracks-release-branches: true is-source-branch-for: ['main'] @@ -11,14 +12,14 @@ branches: main: mode: ContinuousDeployment - label: prealpha + tag: prealpha regex: v2_release is-release-branch: true source-branches: ['develop'] v1_develop: mode: ContinuousDeployment - label: v1_develop + tag: v1_develop regex: v1_develop source-branches: - v1_release @@ -32,9 +33,9 @@ branches: pull-request: mode: ContinuousDeployment - label: PullRequest.{BranchName} + tag: PullRequest.{BranchName} increment: Inherit - label-number-pattern: '[/-](?\d+)' + tag-number-pattern: '[/-](?\d+)' regex: ^(pull|pull\-requests|pr)[/-] source-branches: - develop @@ -55,13 +56,13 @@ ignore: # branches: # # v1_develop: # # mode: ContinuousDeployment -# # label: pre +# # tag: pre # # regex: ^v1_develop?[/-] # # is-release-branch: false # # source-branches: # # - v1 # # v1: -# # label: rc +# # tag: rc # # increment: Patch # # regex: ^v2?[/-] # # is-release-branch: false @@ -70,7 +71,7 @@ ignore: # v2_develop: # mode: ContinuousDeployment -# label: pre +# tag: pre # regex: ^v2_develop?[/-] # is-release-branch: true # tracks-release-branches: true @@ -79,13 +80,13 @@ ignore: # v2: # mode: ContinuousDeployment # is-release-branch: false -# label: alpha +# tag: alpha # increment: Patch # regex: ^v2?[/-] # source-branches: ['v2_develop'] # # feature: -# # label: useBranchName +# # tag: useBranchName # # regex: ^features?[/-] # # source-branches: # # - v1 @@ -94,7 +95,7 @@ ignore: # # - v2_develop # pull-request: -# label: PullRequest.{BranchName} +# tag: PullRequest.{BranchName} # increment: Inherit # ignore: # sha: [] From adcc01ccee746410b12abed0647cd2c2f62cdf08 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 6 Mar 2025 10:36:42 -0700 Subject: [PATCH 2/7] Documented GitVersion.xml --- GitVersion.yml | 96 ++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 53 deletions(-) diff --git a/GitVersion.yml b/GitVersion.yml index 78d807140..60d1da9da 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,8 +1,40 @@ -mode: ContinuousDeployment +# This file is used to configure GitVersion to work with the GitFlow branching strategy. +# +# Terminal.Gui uses the GitFlow branching strategy. +# https://gitversion.net/docs/learn/branching-strategies/gitflow/ +# +# - We have two main branches: `v2_release` and `v2_develop`. +# - `v2_release` is the main branch for V2 releases and always matches the latest release package on Nuget (e.g. 2.0.0); +# prior to release it is a pre-release package (e.g. 2.0.0-prealpha.1). +# - `v2_develop` is the main branch for V2 development and is always a pre-release package (e.g. 2.0.0-develop.1). +# - We do all development work on feature branches off of `v2_develop`. +# - When we deem it time to do a release, we merge the feature branches into `v2_develop` and then `v2_develop` into `v2_release`. +# - The ./.github/workflows/publish.yml file is configured to build and publish on pushes to `v2_develop` and `v2_release`. +# +# We currently use GitVersion 5.1 +# +# Branches: +# - v1_release: This is `main` branch for V1 +# - v1_develop: This is `develop` branch for V1 +# - v2_release: This is `main` branch for V2 +# - v2_develop: This is `develop` branch for V2 +# +# Package Naming: +# - from v2_develop: v2.0.0-develop.1 +# - from v2_release: Prior to Release: v2.0.0-beta.1 or v2.0.0-alpha.1 or v2.0.0-prealpha.1 +# - from v2_release: Release: v2.0.0 +# + +# We prefix our tags with a 'v' or 'V' (e.g. v1.0.0) tag-prefix: '[vV]' + +# This is legacy from v1 and probably can be removed - see tag: develop below continuous-delivery-fallback-tag: dev + branches: +# V2 Branches develop: + # We don't really use ContinuousDeployment, but ContinuousDelivery - I don't remember why we have this here but it works. mode: ContinuousDeployment tag: develop regex: v2_develop @@ -11,12 +43,18 @@ branches: source-branches: [] main: + # We don't really use ContinuousDeployment, but ContinuousDelivery - I don't remember why we have this here but it works. mode: ContinuousDeployment + + # For V2 releases, prior to Alpha we use prealpha. tag: prealpha regex: v2_release is-release-branch: true + + # This tells GitVersion that the main (branch is the source branch for the develop branch. source-branches: ['develop'] +# V1 Branches - These are really just here for reference. v1_develop: mode: ContinuousDeployment tag: v1_develop @@ -31,6 +69,8 @@ branches: is-release-branch: true source-branches: ['v1_develop'] +# Pull Request Branches +# I don't fully understand this, but it seems to work pull-request: mode: ContinuousDeployment tag: PullRequest.{BranchName} @@ -45,58 +85,8 @@ branches: - hotfix pre-release-weight: 30000 +# I don't remember why we have this here but it works. ignore: sha: [] - -# next-version: 2.0.0 -# mode: ContinuousDeployment -# tag-prefix: '[vV]' -# continuous-delivery-fallback-tag: 'pre' -# branches: -# # v1_develop: -# # mode: ContinuousDeployment -# # tag: pre -# # regex: ^v1_develop?[/-] -# # is-release-branch: false -# # source-branches: -# # - v1 -# # v1: -# # tag: rc -# # increment: Patch -# # regex: ^v2?[/-] -# # is-release-branch: false -# # source-branches: [] -# # is-mainline: true - -# v2_develop: -# mode: ContinuousDeployment -# tag: pre -# regex: ^v2_develop?[/-] -# is-release-branch: true -# tracks-release-branches: true -# is-source-branch-for: ['v2'] -# source-branches: [] -# v2: -# mode: ContinuousDeployment -# is-release-branch: false -# tag: alpha -# increment: Patch -# regex: ^v2?[/-] -# source-branches: ['v2_develop'] - -# # feature: -# # tag: useBranchName -# # regex: ^features?[/-] -# # source-branches: -# # - v1 -# # - v1_develop -# # - v2 -# # - v2_develop - -# pull-request: -# tag: PullRequest.{BranchName} -# increment: Inherit -# ignore: -# sha: [] -# merge-message-formats: {} + \ No newline at end of file From e805023c1cfda20eb696dd6061c2fdbd20985b6a Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 6 Mar 2025 11:00:51 -0700 Subject: [PATCH 3/7] upgraded to gitversion 6 --- .github/workflows/publish.yml | 13 ++-- GitVersion.yml | 114 ++++++++++++++++------------------ 2 files changed, 60 insertions(+), 67 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7bee22189..92a78f8ae 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,17 +18,15 @@ jobs: with: fetch-depth: 0 # fetch-depth is needed for GitVersion - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v3 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v3.1.11 with: - versionSpec: '5.x' - includePrerelease: true + versionSpec: '6.0.x' - name: Determine Version - uses: gittools/actions/gitversion/execute@v3 + uses: gittools/actions/gitversion/execute@v3.1.11 with: - useConfigFile: true - #additionalArguments: /b develop + updateProjectFiles: true id: gitversion # step id used as reference for output values - name: Setup dotnet @@ -42,7 +40,6 @@ jobs: - name: Build Release run: | - dotnet-gitversion /updateprojectfiles dotnet build Terminal.Gui/Terminal.Gui.csproj --no-incremental --nologo --force --configuration Release dotnet test Terminal.Gui/Terminal.Gui.csproj --configuration Release diff --git a/GitVersion.yml b/GitVersion.yml index 60d1da9da..41a3cab37 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,92 +1,88 @@ -# This file is used to configure GitVersion to work with the GitFlow branching strategy. +# This file configures GitVersion 6.x to work with Terminal.Gui's GitFlow branching strategy. # -# Terminal.Gui uses the GitFlow branching strategy. +# Terminal.Gui uses the GitFlow branching strategy. # https://gitversion.net/docs/learn/branching-strategies/gitflow/ # # - We have two main branches: `v2_release` and `v2_develop`. -# - `v2_release` is the main branch for V2 releases and always matches the latest release package on Nuget (e.g. 2.0.0); -# prior to release it is a pre-release package (e.g. 2.0.0-prealpha.1). -# - `v2_develop` is the main branch for V2 development and is always a pre-release package (e.g. 2.0.0-develop.1). -# - We do all development work on feature branches off of `v2_develop`. -# - When we deem it time to do a release, we merge the feature branches into `v2_develop` and then `v2_develop` into `v2_release`. -# - The ./.github/workflows/publish.yml file is configured to build and publish on pushes to `v2_develop` and `v2_release`. -# -# We currently use GitVersion 5.1 +# - `v2_release` is the main branch for V2 releases and matches the latest NuGet release package (e.g., 2.0.0); +# prior to release, it uses pre-release labels (e.g., 2.0.0-prealpha.1). +# - `v2_develop` is the development branch for V2 and always carries a pre-release label (e.g., 2.1.0-develop.1). +# - Development happens on feature branches off `v2_develop`. +# - For releases, we merge feature branches into `v2_develop`, then `v2_develop` into `v2_release`. +# - The ./.github/workflows/publish.yml builds and publishes on pushes to `v2_develop` and `v2_release`. # # Branches: -# - v1_release: This is `main` branch for V1 -# - v1_develop: This is `develop` branch for V1 -# - v2_release: This is `main` branch for V2 -# - v2_develop: This is `develop` branch for V2 +# - v1_release: Main branch for V1 (historical) +# - v1_develop: Develop branch for V1 (historical) +# - v2_release: Main branch for V2 +# - v2_develop: Develop branch for V2 # -# Package Naming: -# - from v2_develop: v2.0.0-develop.1 -# - from v2_release: Prior to Release: v2.0.0-beta.1 or v2.0.0-alpha.1 or v2.0.0-prealpha.1 -# - from v2_release: Release: v2.0.0 -# +# Package Naming: +# - from v2_develop: 2.1.0-develop.1 (minor version increments) +# - from v2_release (pre-release): 2.0.0-prealpha.1 or 2.0.0-beta.1 +# - from v2_release (release): 2.0.0 (patch version increments) +# +mode: ContinuousDeployment # GitVersion 6.x uses Mainline mode for GitFlow, focusing on main branch releases -# We prefix our tags with a 'v' or 'V' (e.g. v1.0.0) +# We prefix our tags with 'v' or 'V' (e.g., v1.0.0) tag-prefix: '[vV]' -# This is legacy from v1 and probably can be removed - see tag: develop below -continuous-delivery-fallback-tag: dev - branches: -# V2 Branches + # V2 Development Branch develop: - # We don't really use ContinuousDeployment, but ContinuousDelivery - I don't remember why we have this here but it works. - mode: ContinuousDeployment - tag: develop + # Matches the v2_develop branch regex: v2_develop - tracks-release-branches: true - is-source-branch-for: ['main'] + # Adds 'develop' as pre-release label (e.g., 2.1.0-develop.1) + label: develop + # Increments minor version (x.y+1.z) on commits + increment: Minor + # No source branches specified as this is the root of development source-branches: [] + # Indicates this branch feeds into release branches + tracks-release-branches: true + # V2 Release Branch main: - # We don't really use ContinuousDeployment, but ContinuousDelivery - I don't remember why we have this here but it works. - mode: ContinuousDeployment - - # For V2 releases, prior to Alpha we use prealpha. - tag: prealpha + # Matches the v2_release branch regex: v2_release - is-release-branch: true - - # This tells GitVersion that the main (branch is the source branch for the develop branch. + # Uses 'prealpha' as pre-release label before official release + label: prealpha + # Increments patch version (x.y.z+1) on commits + increment: Patch + # Specifies v2_develop as the source branch source-branches: ['develop'] -# V1 Branches - These are really just here for reference. + # V1 Branches - Included for historical reference v1_develop: - mode: ContinuousDeployment - tag: v1_develop regex: v1_develop - source-branches: - - v1_release + label: v1_develop + increment: Minor + source-branches: ['v1_release'] + # Lower weight keeps V1 pre-releases sorted below V2 pre-release-weight: 100 v1_release: - mode: ContinuousDeployment regex: v1_release - is-release-branch: true + # Empty label for stable releases + label: '' + increment: Patch source-branches: ['v1_develop'] -# Pull Request Branches -# I don't fully understand this, but it seems to work + # Pull Request Branches + # Configures versioning for PRs (e.g., 2.0.0-pr.feature-123.1) pull-request: - mode: ContinuousDeployment - tag: PullRequest.{BranchName} - increment: Inherit - tag-number-pattern: '[/-](?\d+)' + # Matches typical PR branch names regex: ^(pull|pull\-requests|pr)[/-] + # Uses 'pr' prefix with branch name in the label (e.g., pr.feature-123) + label: pr.{BranchName} + # Inherits increment strategy from source branch + increment: Inherit source-branches: - - develop - - main - - feature - - support - - hotfix + - develop + - main + # High weight ensures PR versions sort after regular pre-releases pre-release-weight: 30000 -# I don't remember why we have this here but it works. +# Ignore specific commits if needed (currently empty) ignore: - sha: [] - - \ No newline at end of file + sha: [] \ No newline at end of file From 73e230b87729ddb545d82349747879dc5c351219 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 6 Mar 2025 11:17:57 -0700 Subject: [PATCH 4/7] upgraded to gitversion 6 --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 92a78f8ae..545f59605 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,7 +26,8 @@ jobs: - name: Determine Version uses: gittools/actions/gitversion/execute@v3.1.11 with: - updateProjectFiles: true + useConfigFile: true + updateAssemblyInfo: true id: gitversion # step id used as reference for output values - name: Setup dotnet From fe18c81dc95a8174ee0d5a4f140c2fc95525d86b Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 6 Mar 2025 12:48:44 -0700 Subject: [PATCH 5/7] Fixed gitversion --- GitVersion.yml | 53 ++++++++++++++++++++-------------------- Scripts/delist-nuget.ps1 | 4 +-- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/GitVersion.yml b/GitVersion.yml index 41a3cab37..b2ba90ee1 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -22,12 +22,24 @@ # - from v2_release (pre-release): 2.0.0-prealpha.1 or 2.0.0-beta.1 # - from v2_release (release): 2.0.0 (patch version increments) # -mode: ContinuousDeployment # GitVersion 6.x uses Mainline mode for GitFlow, focusing on main branch releases +mode: ContinuousDelivery # GitVersion 6.x uses Mainline mode for GitFlow, focusing on main branch releases # We prefix our tags with 'v' or 'V' (e.g., v1.0.0) tag-prefix: '[vV]' branches: + + # V2 Release Branch + main: + # Matches the v2_release branch + regex: ^v2_release$ + # Uses 'prealpha' as pre-release label before official release + label: prealpha + # Increments patch version (x.y.z+1) on commits + increment: Patch + # Specifies v2_develop as the source branch + source-branches: ['develop'] + # V2 Development Branch develop: # Matches the v2_develop branch @@ -41,32 +53,21 @@ branches: # Indicates this branch feeds into release branches tracks-release-branches: true - # V2 Release Branch - main: - # Matches the v2_release branch - regex: v2_release - # Uses 'prealpha' as pre-release label before official release - label: prealpha - # Increments patch version (x.y.z+1) on commits - increment: Patch - # Specifies v2_develop as the source branch - source-branches: ['develop'] + # # V1 Branches - Included for historical reference + # v1_develop: + # regex: v1_develop + # label: v1_develop + # increment: Minor + # source-branches: ['v1_release'] + # # Lower weight keeps V1 pre-releases sorted below V2 + # pre-release-weight: 100 - # V1 Branches - Included for historical reference - v1_develop: - regex: v1_develop - label: v1_develop - increment: Minor - source-branches: ['v1_release'] - # Lower weight keeps V1 pre-releases sorted below V2 - pre-release-weight: 100 - - v1_release: - regex: v1_release - # Empty label for stable releases - label: '' - increment: Patch - source-branches: ['v1_develop'] + # v1_release: + # regex: v1_release + # # Empty label for stable releases + # label: '' + # increment: Patch + # source-branches: ['v1_develop'] # Pull Request Branches # Configures versioning for PRs (e.g., 2.0.0-pr.feature-123.1) diff --git a/Scripts/delist-nuget.ps1 b/Scripts/delist-nuget.ps1 index 9b0321dfe..23bb10094 100644 --- a/Scripts/delist-nuget.ps1 +++ b/Scripts/delist-nuget.ps1 @@ -1,8 +1,8 @@ -$apiKey = "key" # Replace with your actual API key +$apiKey = "" # Replace with your actual API key # Unlist all packages matching "2.0.0-v2-develop.*" # PowerShell script to unlist NuGet packages using dotnet CLI $packageId = "terminal.gui" # Ensure this is the correct package name (case-sensitive) -$packagePattern = "^2\.0\.0-v2-develop\..*$" # Regex pattern for filtering versions +$packagePattern = "^2\.0\.0-develop\..*$" # Regex pattern for filtering versions $nugetSource = "https://api.nuget.org/v3/index.json" # Fetch package versions from NuGet API From 7162ed850c092addd3d96bd8b6576f5d10dc8cc8 Mon Sep 17 00:00:00 2001 From: Thomas Nind <31306100+tznind@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:14:15 +0000 Subject: [PATCH 6/7] Fix v2 not raising closing events (#3961) --- .../ConsoleDrivers/V2/ApplicationV2.cs | 20 ++++++++ .../ConsoleDrivers/V2/ApplicationV2Tests.cs | 47 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Terminal.Gui/ConsoleDrivers/V2/ApplicationV2.cs b/Terminal.Gui/ConsoleDrivers/V2/ApplicationV2.cs index 41e0a5b4b..6ccf8a54b 100644 --- a/Terminal.Gui/ConsoleDrivers/V2/ApplicationV2.cs +++ b/Terminal.Gui/ConsoleDrivers/V2/ApplicationV2.cs @@ -194,6 +194,23 @@ public class ApplicationV2 : ApplicationImpl { Logging.Logger.LogInformation ($"RequestStop '{top}'"); + top ??= Application.Top; + + if (top == null) + { + return; + } + + var ev = new ToplevelClosingEventArgs (top); + top.OnClosing (ev); + + if (ev.Cancel) + { + return; + } + + top.Running = false; + // TODO: This definition of stop seems sketchy Application.TopLevels.TryPop (out _); @@ -205,6 +222,9 @@ public class ApplicationV2 : ApplicationImpl { Application.Top = null; } + + // Notify that it is closed + top.OnClosed (top); } /// diff --git a/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs b/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs index ed1185b38..550000778 100644 --- a/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs +++ b/Tests/UnitTests/ConsoleDrivers/V2/ApplicationV2Tests.cs @@ -221,6 +221,53 @@ public class ApplicationV2Tests ApplicationImpl.ChangeInstance (orig); } + + [Fact] + public void Test_V2_ClosingRaised () + { + var orig = ApplicationImpl.Instance; + + var v2 = NewApplicationV2 (); + ApplicationImpl.ChangeInstance (v2); + + v2.Init (); + + int closing=0; + int closed = 0; + var t=new Toplevel (); + t.Closing + += (_, a) => + { + // Cancel the first time + if (closing==0) + { + a.Cancel = true; + } + closing++; + Assert.Same(t,a.RequestingTop); + }; + + t.Closed + += (_, a) => + { + closed++; + Assert.Same (t, a.Toplevel); + }; + + v2.AddIdle (IdleExit); + + // Blocks until the timeout call is hit + + v2.Run (t); + + Assert.Null (Application.Top); + v2.Shutdown (); + + ApplicationImpl.ChangeInstance (orig); + + Assert.Equal (2,closing); + Assert.Equal (1, closed); + } private bool IdleExit () { if (Application.Top != null) From 85cf6619ed6f2eb8d8f543fd3f2cce19d79798a5 Mon Sep 17 00:00:00 2001 From: BDisp Date: Thu, 6 Mar 2025 21:06:51 +0000 Subject: [PATCH 7/7] Fixes #3956. MessageBox doesn't return the index of IsDefault button (#3958) * Fixes #3956. MessageBox doesn't return the index of IsDefault button * Change to Theory test. * Fix unit test 'Error opening terminal: unknown.' * Remove RunningUnitTests = true because constructor already set it. --------- Co-authored-by: Tig --- Terminal.Gui/Views/MessageBox.cs | 4 ++++ Tests/UnitTests/Dialogs/MessageBoxTests.cs | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index cd14dfc4f..31b4a41ec 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -374,6 +374,10 @@ public static class MessageBox { Clicked = (int)btn.Data!; } + else + { + Clicked = defaultButton; + } e.Cancel = true; Application.RequestStop (); diff --git a/Tests/UnitTests/Dialogs/MessageBoxTests.cs b/Tests/UnitTests/Dialogs/MessageBoxTests.cs index 50765272f..c873686f7 100644 --- a/Tests/UnitTests/Dialogs/MessageBoxTests.cs +++ b/Tests/UnitTests/Dialogs/MessageBoxTests.cs @@ -504,5 +504,25 @@ public class MessageBoxTests Application.Run (top); top.Dispose (); } -} + [Theory] + [SetupFakeDriver] + [MemberData (nameof (AcceptingKeys))] + public void Button_IsDefault_True_Return_His_Index_On_Accepting (Key key) + { + Application.Init (); + + Application.Iteration += (_, _) => Assert.True (Application.RaiseKeyDownEvent (key)); + int res = MessageBox.Query ("hey", "IsDefault", "Yes", "No"); + + Assert.Equal (0, res); + + Application.Shutdown (); + } + + public static IEnumerable AcceptingKeys () + { + yield return [Key.Enter]; + yield return [Key.Space]; + } +}