瀏覽代碼

Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop

Tig 4 月之前
父節點
當前提交
58610dedbc

+ 5 - 7
.github/workflows/publish.yml

@@ -18,17 +18,16 @@ 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
+        updateAssemblyInfo: true
       id: gitversion # step id used as reference for output values
 
     - name: Setup dotnet
@@ -42,7 +41,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
 

+ 74 - 86
GitVersion.yml

@@ -1,101 +1,89 @@
-workflow: GitFlow/v1
+# This file configures GitVersion 6.x to work with Terminal.Gui's 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 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: 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: 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: 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:
-  develop:
-    mode: ContinuousDeployment
-    label: develop
-    regex: v2_develop
-    tracks-release-branches: true
-    is-source-branch-for: ['main']
-    source-branches: []
 
+  # V2 Release Branch
   main:
-    mode: ContinuousDeployment
+    # Matches the v2_release branch
+    regex: ^v2_release$
+    # Uses 'prealpha' as pre-release label before official release
     label: prealpha
-    regex: v2_release
-    is-release-branch: true
+    # Increments patch version (x.y.z+1) on commits
+    increment: Patch
+    # Specifies v2_develop as the source branch
     source-branches: ['develop']
 
-  v1_develop:
-    mode: ContinuousDeployment
-    label: v1_develop
-    regex: v1_develop
-    source-branches:
-    - v1_release
-    pre-release-weight: 100
+  # V2 Development Branch
+  develop:
+    # Matches the v2_develop branch
+    regex: v2_develop
+    # 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
 
-  v1_release:
-    mode: ContinuousDeployment
-    regex: v1_release
-    is-release-branch: true
-    source-branches: ['v1_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_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)
   pull-request:
-    mode: ContinuousDeployment
-    label: PullRequest.{BranchName}
-    increment: Inherit
-    label-number-pattern: '[/-](?<number>\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
 
+# Ignore specific commits if needed (currently empty)
 ignore:
-  sha: []
-
-
-# next-version: 2.0.0
-# mode: ContinuousDeployment
-# tag-prefix: '[vV]'
-# continuous-delivery-fallback-tag: 'pre'
-# branches:
-#   # v1_develop:
-#   #   mode: ContinuousDeployment
-#   #   label: pre
-#   #   regex: ^v1_develop?[/-]
-#   #   is-release-branch: false
-#   #   source-branches:
-#   #   - v1
-#   # v1:
-#   #   label: rc
-#   #   increment: Patch
-#   #   regex: ^v2?[/-]
-#   #   is-release-branch: false
-#   #   source-branches: []
-#   #   is-mainline: true
-
-#   v2_develop:
-#     mode: ContinuousDeployment
-#     label: 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
-#     label: alpha
-#     increment: Patch
-#     regex: ^v2?[/-]
-#     source-branches: ['v2_develop']
-
-#   # feature:
-#   #   label: useBranchName
-#   #   regex: ^features?[/-]
-#   #   source-branches:
-#   #   - v1
-#   #   - v1_develop
-#   #   - v2
-#   #   - v2_develop
- 
-#   pull-request:
-#     label: PullRequest.{BranchName}
-#     increment: Inherit
-# ignore:
-#   sha: []
-# merge-message-formats: {}
+  sha: []

+ 2 - 2
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

+ 20 - 0
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);
     }
 
     /// <inheritdoc/>

+ 4 - 0
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 ();

+ 47 - 0
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)

+ 21 - 1
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<object []> AcceptingKeys ()
+    {
+        yield return [Key.Enter];
+        yield return [Key.Space];
+    }
+}