mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix(pr,time,release): closed PRs for checkout and edit, dismiss state check first, worktree-aware checkout errors, exact piped durations (follow gh)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
11 files changed
+131
-23
No files matched your search
@@ -17,6 +17,7 @@ type checkoutRunner struct {
|
||||
dirty, collision bool
|
||||
localCommit string
|
||||
diverged bool
|
||||
worktrees string
|
||||
}
|
||||
|
||||
func (r *checkoutRunner) Output(_ context.Context, dir string, prompt bool, args ...string) (string, error) {
|
||||
@@ -38,6 +39,8 @@ func (r *checkoutRunner) Output(_ context.Context, dir string, prompt bool, args
|
||||
return "true", nil
|
||||
}
|
||||
return "abc123", nil
|
||||
case "worktree":
|
||||
return r.worktrees, nil
|
||||
case "status":
|
||||
if r.dirty {
|
||||
return "?? file", nil
|
||||
@@ -172,3 +175,19 @@ func TestPullCheckoutTracksHeadBranch(t *testing.T) {
|
||||
require.NotContains(t, call, "refs/pull/")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullCheckoutRejectsBranchCheckedOutInAnotherWorktree(t *testing.T) {
|
||||
options := CheckoutOptions{Directory: "/work", Remote: "origin", Number: 7, Branch: "pr/7", ExpectedCommit: "abc123", Update: true}
|
||||
runner := &checkoutRunner{collision: true, localCommit: "abc123", worktrees: "worktree abc123\nHEAD 1\nbranch refs/heads/main\n\nworktree /other/tree\nHEAD 2\nbranch refs/heads/pr/7\n"}
|
||||
_, err := CheckoutPull(context.Background(), runner, options)
|
||||
require.ErrorContains(t, err, `branch "pr/7" is checked out in the worktree /other/tree`)
|
||||
require.ErrorContains(t, err, "--detach")
|
||||
for _, call := range runner.calls {
|
||||
require.NotContains(t, call, "fetch")
|
||||
require.NotContains(t, call, "switch")
|
||||
}
|
||||
// The current worktree holding the branch is fine.
|
||||
runner = &checkoutRunner{collision: true, localCommit: "abc123", worktrees: "worktree abc123\nHEAD 1\nbranch refs/heads/pr/7\n"}
|
||||
_, err = CheckoutPull(context.Background(), runner, options)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
Reference in new issue
Block a user