diff --git a/desktop/internal/core/git_push.go b/desktop/internal/core/git_push.go index 73ebee0ad1..43c64223b6 100644 --- a/desktop/internal/core/git_push.go +++ b/desktop/internal/core/git_push.go @@ -1,9 +1,6 @@ package core -import ( - "context" - "encoding/json" -) +import "context" // GitPushTags says which tags a push sends along with the branch. type GitPushTags string @@ -88,18 +85,9 @@ type expectedPush struct { // GitPush starts git and blocks; call it from a background goroutine and observe its progress // with WithGitProgress. func (c *Client) GitPush(ctx context.Context, root string, preview GitPushPreview, tags GitPushTags, target PushTargetChoice, force bool) error { - reviewed := expectedPush{ - LocalBranch: preview.LocalBranch, LocalHead: preview.LocalHead, Remote: preview.Remote, - RemoteBranch: preview.RemoteBranch, TargetKind: preview.TargetKind, - RemoteTrackingOID: preview.RemoteTrackingOID, Tags: nonNil(preview.Tags), - } - raw, err := json.Marshal(reviewed) + request, err := pushRequest(root, preview, tags, target, force) if err != nil { return err } - return c.gitWrite(ctx, gitWriteRequest{ - Root: root, Operation: "push", Force: force, PushTags: string(tags), PushTarget: string(target), - ExpectedPush: raw, - GitReference: &gitReferenceRequest{FullName: "refs/heads/" + preview.LocalBranch, ShortName: preview.LocalBranch, Kind: "local"}, - }) + return c.gitWrite(ctx, request) } diff --git a/desktop/internal/core/git_workspace_push.go b/desktop/internal/core/git_workspace_push.go new file mode 100644 index 0000000000..03e4fd896b --- /dev/null +++ b/desktop/internal/core/git_workspace_push.go @@ -0,0 +1,103 @@ +package core + +import ( + "context" + "encoding/json" +) + +// WorkspacePushState is whether a repository of a workspace push can push, and why not. +type WorkspacePushState string + +const ( + // WorkspacePushReady has commits to send, or a remote branch to create. + WorkspacePushReady WorkspacePushState = "ready" + // WorkspacePushUpToDate is a branch its remote already has. + WorkspacePushUpToDate WorkspacePushState = "upToDate" + // WorkspacePushNoRemote is a repository without a remote. + WorkspacePushNoRemote WorkspacePushState = "noRemote" + // WorkspacePushEmpty is a branch without a commit yet. + WorkspacePushEmpty WorkspacePushState = "emptyRepository" + // WorkspacePushDetached is a repository whose HEAD names a commit instead of a branch. + WorkspacePushDetached WorkspacePushState = "detachedHead" + // WorkspacePushFailed is a repository Git could not read or resolve; Detail says why. + WorkspacePushFailed WorkspacePushState = "failed" +) + +// WorkspacePushRepository is Core's push review of one repository of a workspace push. +type WorkspacePushRepository struct { + ID string `json:"id"` + State WorkspacePushState `json:"state"` + // Branch is the checked-out branch, empty when HEAD is detached or the repository could + // not be read. + Branch string `json:"branch"` + // Preview is the push review of a ready or up-to-date repository, nil otherwise. + Preview *GitPushPreview `json:"preview"` + // NeedsTarget reports a divergent upstream no destination was picked for. + NeedsTarget bool `json:"needsTarget"` + // Records are the listed repositories this one records as submodules. They come earlier + // in the list, and this one should not push after one of them failed to. + Records []string `json:"records"` + Detail string `json:"detail"` +} + +type workspacePushPreviewRequest struct { + Repositories []WorkspaceCommitRepository `json:"repositories"` + Limit int `json:"limit,omitempty"` + PushTags GitPushTags `json:"pushTags,omitempty"` + PushTargets map[string]PushTargetChoice `json:"pushTargets,omitempty"` +} + +// WorkspacePushPreview reviews pushing the checked-out branch of every repository, as IDEA's +// Push dialog lists them. The answer is in push order: a submodule before every listed +// repository that records it. targets answers divergent upstreams by repository ID. +// +// WorkspacePushPreview starts git and blocks; call it from a background goroutine. +func (c *Client) WorkspacePushPreview(ctx context.Context, repositories []WorkspaceCommitRepository, tags GitPushTags, targets map[string]PushTargetChoice) ([]WorkspacePushRepository, error) { + request := workspacePushPreviewRequest{Repositories: nonNil(repositories), Limit: 100, PushTags: tags, PushTargets: targets} + var response struct { + Repositories []WorkspacePushRepository `json:"repositories"` + } + if err := c.Execute(ctx, "git.workspacePushPreview", request, &response); err != nil { + return nil, err + } + for i := range response.Repositories { + r := &response.Repositories[i] + r.Records = nonNil(r.Records) + if r.Preview != nil { + r.Preview.Tags = nonNil(r.Preview.Tags) + r.Preview.Commits = nonNil(r.Preview.Commits) + } + } + return nonNil(response.Repositories), nil +} + +// GitPushInWorkspace is GitPush for one repository of a workspace push: Git also refuses the +// push while a submodule commit it records is on no remote (--recurse-submodules=check). +// +// GitPushInWorkspace starts git and blocks; call it from a background goroutine. +func (c *Client) GitPushInWorkspace(ctx context.Context, root string, preview GitPushPreview, tags GitPushTags, target PushTargetChoice) error { + request, err := pushRequest(root, preview, tags, target, false) + if err != nil { + return err + } + request.CheckSubmodules = true + return c.gitWrite(ctx, request) +} + +// pushRequest is the git.write request of a push validated against preview. +func pushRequest(root string, preview GitPushPreview, tags GitPushTags, target PushTargetChoice, force bool) (gitWriteRequest, error) { + reviewed := expectedPush{ + LocalBranch: preview.LocalBranch, LocalHead: preview.LocalHead, Remote: preview.Remote, + RemoteBranch: preview.RemoteBranch, TargetKind: preview.TargetKind, + RemoteTrackingOID: preview.RemoteTrackingOID, Tags: nonNil(preview.Tags), + } + raw, err := json.Marshal(reviewed) + if err != nil { + return gitWriteRequest{}, err + } + return gitWriteRequest{ + Root: root, Operation: "push", Force: force, PushTags: string(tags), PushTarget: string(target), + ExpectedPush: raw, + GitReference: &gitReferenceRequest{FullName: "refs/heads/" + preview.LocalBranch, ShortName: preview.LocalBranch, Kind: "local"}, + }, nil +} diff --git a/desktop/internal/core/gitcommit.go b/desktop/internal/core/gitcommit.go index cdd4aaa0c2..a246a060dd 100644 --- a/desktop/internal/core/gitcommit.go +++ b/desktop/internal/core/gitcommit.go @@ -44,6 +44,8 @@ type gitWriteRequest struct { PushTags string `json:"pushTags,omitempty"` PushTarget string `json:"pushTarget,omitempty"` ExpectedPush json.RawMessage `json:"expectedPush,omitempty"` + // CheckSubmodules has Git refuse a push while a submodule commit it records is on no remote. + CheckSubmodules bool `json:"checkSubmodules,omitempty"` // NoCheckout registers a created worktree without filling its directory. NoCheckout bool `json:"noCheckout,omitempty"` // Lightweight makes createTag a lightweight tag, which takes no message. @@ -303,9 +305,11 @@ type WorkspaceCommitSession struct { // OrderedIDs are the repositories of the plan in the order they commit: a child before the // parent that records it. OrderedIDs []string - Message string - Amend bool - Push bool + // Repositories are the repositories the plan binds, as the request and Core listed them. + Repositories []WorkspaceCommitRepository + Message string + Amend bool + Push bool // Author is the "Name " the plan records its commits under, empty for the // configured identity. Author string @@ -352,14 +356,15 @@ func (s *WorkspaceCommitSession) UnmarshalJSON(data []byte) error { return err } var plan struct { - Message string `json:"message"` - Amend bool `json:"amend"` - Push bool `json:"push"` - Author string `json:"author"` - SignOff bool `json:"signOff"` - IsRetry bool `json:"isRetry"` - OrderedIDs []string `json:"orderedIds"` - States map[string]WorkspaceCommitState `json:"states"` + Message string `json:"message"` + Amend bool `json:"amend"` + Push bool `json:"push"` + Author string `json:"author"` + SignOff bool `json:"signOff"` + IsRetry bool `json:"isRetry"` + OrderedIDs []string `json:"orderedIds"` + Repositories []WorkspaceCommitRepository `json:"repositories"` + States map[string]WorkspaceCommitState `json:"states"` } if len(wire.Plan) == 0 { return errors.New("workspace commit session has no plan") @@ -371,6 +376,7 @@ func (s *WorkspaceCommitSession) UnmarshalJSON(data []byte) error { raw: append(json.RawMessage(nil), data...), plan: append(json.RawMessage(nil), wire.Plan...), OrderedIDs: plan.OrderedIDs, + Repositories: plan.Repositories, Message: plan.Message, Amend: plan.Amend, Push: plan.Push, diff --git a/desktop/internal/core/gitlog.go b/desktop/internal/core/gitlog.go index b4b17d4b9c..fdf3e53dd5 100644 --- a/desktop/internal/core/gitlog.go +++ b/desktop/internal/core/gitlog.go @@ -54,6 +54,9 @@ type GitHistoryPage struct { // NextCursor continues the walk with GitHistoryPage; empty when the page reaches the end. NextCursor string `json:"nextCursor,omitempty"` HasMore bool `json:"hasMore"` + // LimitReached says the walk stopped at the most commits its first page asked for while + // the history goes on; HasMore is then false. + LimitReached bool `json:"limitReached,omitempty"` } // GitCommitFile is one path a commit changed. @@ -85,6 +88,8 @@ type gitHistoryPageRequest struct { Order string `json:"order"` Cursor string `json:"cursor,omitempty"` Limit int `json:"limit"` + // MaxCommits is the most commits the walk reads in all; zero leaves it to the kernel. + MaxCommits int `json:"maxCommits,omitempty"` } type gitCursorRequest struct { @@ -122,9 +127,13 @@ func (c *Client) GitReferences(ctx context.Context, root string) (GitReferences, // minutes and keeps at most eight, so a stale cursor fails and the history is reloaded. // A walk that is not continued to its end should be released with CloseGitHistoryCursor. // +// maxCommits, 1 to 100,000, is the most commits the walk reads in all, fixed by its first +// page; zero is the kernel's 5,000 on a first page and the walk's own bound on a later one. +// The page that stops at the bound while the history goes on says LimitReached. +// // GitHistoryPage starts git and blocks; call it from a background goroutine. -func (c *Client) GitHistoryPage(ctx context.Context, root, reference, cursor string, limit int) (GitHistoryPage, error) { - request := gitHistoryPageRequest{Root: root, Reference: reference, Order: "date", Cursor: cursor, Limit: limit} +func (c *Client) GitHistoryPage(ctx context.Context, root, reference, cursor string, limit, maxCommits int) (GitHistoryPage, error) { + request := gitHistoryPageRequest{Root: root, Reference: reference, Order: "date", Cursor: cursor, Limit: limit, MaxCommits: maxCommits} var page GitHistoryPage if err := c.Execute(ctx, "git.historyPage", request, &page); err != nil { return GitHistoryPage{}, err diff --git a/desktop/internal/core/repository_discovery_test.go b/desktop/internal/core/repository_discovery_test.go index 772f714dcd..3bac296abe 100644 --- a/desktop/internal/core/repository_discovery_test.go +++ b/desktop/internal/core/repository_discovery_test.go @@ -58,12 +58,14 @@ func TestWorkspaceRepositorySelectionUsesCoreFixtures(t *testing.T) { Request struct { Repositories []WorkspaceRepository `json:"repositories"` Selected string `json:"selected"` - Chosen []string `json:"chosen"` + // Chosen is nil when the case picks one repository, not several. + Chosen *[]string `json:"chosen"` } `json:"request"` Response struct { Active *string `json:"active"` FellBack bool `json:"fellBack"` Others []string `json:"others"` + Chosen []string `json:"chosen"` } `json:"response"` } `json:"cases"` } @@ -74,28 +76,24 @@ func TestWorkspaceRepositorySelectionUsesCoreFixtures(t *testing.T) { t.Fatal("the selection fixture has no cases") } client := NewClient() - checked := 0 for _, item := range fixture.Cases { - if item.Request.Chosen != nil { - // A view acting on several repositories at once sends chosen instead of selected; - // the bridge does not, until the Git Log takes several repositories (#2013). - continue - } - checked++ t.Run(item.Name, func(t *testing.T) { - want := WorkspaceRepositorySelection{FellBack: item.Response.FellBack, Others: item.Response.Others} + want := WorkspaceRepositorySelection{FellBack: item.Response.FellBack, Others: item.Response.Others, Chosen: item.Response.Chosen} if item.Response.Active != nil { want.Active = *item.Response.Active } - got, err := client.SelectWorkspaceRepository(testContext(t), item.Request.Repositories, item.Request.Selected) + var got WorkspaceRepositorySelection + var err error + if item.Request.Chosen != nil { + got, err = client.SelectWorkspaceRepositories(testContext(t), item.Request.Repositories, *item.Request.Chosen) + } else { + got, err = client.SelectWorkspaceRepository(testContext(t), item.Request.Repositories, item.Request.Selected) + } if err != nil || !reflect.DeepEqual(got, want) { t.Fatalf("selection = %#v, error = %v; want %#v", got, err, want) } }) } - if checked == 0 { - t.Fatal("the selection fixture has no case with selected") - } duplicate := []WorkspaceRepository{ {Path: "/w/a", ID: "a", Name: "a", Role: RepositoryNested}, {Path: "/w/b", ID: "a", Name: "a", Role: RepositoryNested}, @@ -104,6 +102,42 @@ func TestWorkspaceRepositorySelectionUsesCoreFixtures(t *testing.T) { requireCode(t, err, CodeInvalidRequest) } +// The bridge sends each repository's loaded history and decodes Core's merged rows; the order and +// the keys are the fixtures' and Core's. +func TestWorkspaceHistoryMergeUsesCoreFixtures(t *testing.T) { + data, err := os.ReadFile(contractfixture.CoreFixture("git/workspace-history-merge-v1.json")) + if err != nil { + t.Fatal(err) + } + var fixture struct { + Cases []struct { + Name string `json:"name"` + Request struct { + Repositories []WorkspaceHistory `json:"repositories"` + } `json:"request"` + Response WorkspaceHistoryMerge `json:"response"` + } `json:"cases"` + } + if err := json.Unmarshal(data, &fixture); err != nil { + t.Fatal(err) + } + if len(fixture.Cases) == 0 { + t.Fatal("the merge fixture has no cases") + } + client := NewClient() + for _, item := range fixture.Cases { + t.Run(item.Name, func(t *testing.T) { + got, err := client.MergeWorkspaceHistories(testContext(t), item.Request.Repositories) + if err != nil || !reflect.DeepEqual(got, item.Response) { + t.Fatalf("merge = %#v, error = %v; want %#v", got, err, item.Response) + } + }) + } + repeated := []WorkspaceHistory{{ID: "a", Complete: true}, {ID: "a", Complete: true}} + _, err = client.MergeWorkspaceHistories(testContext(t), repeated) + requireCode(t, err, CodeInvalidRequest) +} + func TestWorkspaceChangeGroupsUseCoreFixtures(t *testing.T) { data, err := os.ReadFile(contractfixture.CoreFixture("git/workspace-change-groups-v1.json")) if err != nil { diff --git a/desktop/internal/core/workspace.go b/desktop/internal/core/workspace.go index 1e1ad80a2b..24a0a76482 100644 --- a/desktop/internal/core/workspace.go +++ b/desktop/internal/core/workspace.go @@ -40,6 +40,85 @@ type WorkspaceRepositorySelection struct { // Others are every other ID in discovery order: the repositories the view lists to // switch to. Others []string + // Chosen are the repositories a view that walks several acts on, in discovery order, the + // first of them Active; set only by SelectWorkspaceRepositories. + Chosen []string +} + +// SelectWorkspaceRepositories asks Core which repositories a view that walks several acts on, +// given the discovery list and the IDs the view chose before. Core keeps the chosen ones still +// listed and falls back to one repository when none is. +func (c *Client) SelectWorkspaceRepositories(ctx context.Context, repositories []WorkspaceRepository, chosen []string) (WorkspaceRepositorySelection, error) { + request := struct { + Repositories []WorkspaceRepository `json:"repositories"` + Chosen []string `json:"chosen"` + }{nonNil(repositories), nonNil(chosen)} + var response struct { + Active *string `json:"active"` + FellBack bool `json:"fellBack"` + Others []string `json:"others"` + Chosen []string `json:"chosen"` + } + if err := c.Execute(ctx, "git.workspaceRepositorySelection", request, &response); err != nil { + return WorkspaceRepositorySelection{}, err + } + selection := WorkspaceRepositorySelection{FellBack: response.FellBack, Others: response.Others, Chosen: response.Chosen} + if response.Active != nil { + selection.Active = *response.Active + } + return selection, nil +} + +// WorkspaceHistory is the history of one repository a log walks with others, as far as it is +// loaded. +type WorkspaceHistory struct { + ID string `json:"id"` + Commits []WorkspaceHistoryCommit `json:"commits"` + // Complete says Commits hold the whole walk, so no page is left to load. + Complete bool `json:"complete"` +} + +// WorkspaceHistoryCommit is one loaded commit as the merge places it. +type WorkspaceHistoryCommit struct { + Hash string `json:"hash"` + ParentHashes []string `json:"parentHashes"` + // Timestamp is the commit's Unix seconds, nil when Git reported no valid date. + Timestamp *int64 `json:"timestamp,omitempty"` +} + +// WorkspaceHistoryEntry is one row of the merged list: the commit at Index of the history at +// Repository in the request, and its key and its parents' keys in the merged graph. +type WorkspaceHistoryEntry struct { + Repository int `json:"repository"` + Index int `json:"index"` + Key string `json:"key"` + ParentKeys []string `json:"parentKeys"` +} + +// WorkspaceHistoryMerge is Core's merged list, newest first, and the indices of the histories +// whose next page it waits on before it places more. +type WorkspaceHistoryMerge struct { + Entries []WorkspaceHistoryEntry `json:"entries"` + Pending []int `json:"pending"` +} + +// MergeWorkspaceHistories asks Core to interleave the loaded histories of several repositories +// by date, each in its own order (git.workspaceHistoryMerge). +func (c *Client) MergeWorkspaceHistories(ctx context.Context, histories []WorkspaceHistory) (WorkspaceHistoryMerge, error) { + for i := range histories { + histories[i].Commits = nonNil(histories[i].Commits) + for j := range histories[i].Commits { + histories[i].Commits[j].ParentHashes = nonNil(histories[i].Commits[j].ParentHashes) + } + } + request := struct { + Repositories []WorkspaceHistory `json:"repositories"` + }{nonNil(histories)} + var merged WorkspaceHistoryMerge + if err := c.Execute(ctx, "git.workspaceHistoryMerge", request, &merged); err != nil { + return WorkspaceHistoryMerge{}, err + } + return merged, nil } // SelectWorkspaceRepository asks Core which repository a view acts on, given the discovery diff --git a/desktop/internal/i18n/en.go b/desktop/internal/i18n/en.go index 96ea4a19d1..4c45956548 100644 --- a/desktop/internal/i18n/en.go +++ b/desktop/internal/i18n/en.go @@ -81,6 +81,10 @@ var english = Messages{ LoadMore: Shared(English, "git.log.loadMore"), LoadingCommits: Shared(English, "git.log.loadingCommits"), LoadMoreFailed: Shared(English, "desktop.git.loadMoreFailed"), + LimitReached: func(count int) string { + return SharedFormat(English, "desktop.git.log.limitReached", map[string]string{"count": strconv.Itoa(count)}) + }, + AdjustLimit: Shared(English, "desktop.git.log.adjustLimit"), SelectCommit: Shared(English, "git.log.selectCommit"), LoadingFiles: Shared(English, "git.log.loadingChangedFiles"), FilesFailed: Shared(English, "desktop.git.filesFailed"), diff --git a/desktop/internal/i18n/git_repo_messages.go b/desktop/internal/i18n/git_repo_messages.go index ba61859a7b..e75fd6e9aa 100644 --- a/desktop/internal/i18n/git_repo_messages.go +++ b/desktop/internal/i18n/git_repo_messages.go @@ -1,10 +1,15 @@ package i18n +import "strconv" + // GitRepositoryMessages label the repository the Git log walks: the header of the commit list names -// it, and offers the way back to the project's own repository while a nested one is walked. +// it, or counts the repositories it walks together, lists the repositories to walk on a click, and +// offers the way back to the project's own repository while a nested one is walked. type GitRepositoryMessages struct { Current func(name string) string Back func(name string) string + Several func(count int) string + Choose string } func gitRepositoryMessages(language Language) GitRepositoryMessages { @@ -15,5 +20,9 @@ func gitRepositoryMessages(language Language) GitRepositoryMessages { Back: func(name string) string { return SharedFormat(language, "desktop.git.repo.back", map[string]string{"name": name}) }, + Several: func(count int) string { + return SharedFormat(language, "desktop.git.repo.several", map[string]string{"count": strconv.Itoa(count)}) + }, + Choose: Shared(language, "desktop.git.repo.choose"), } } diff --git a/desktop/internal/i18n/messages.go b/desktop/internal/i18n/messages.go index 442911e7f1..85808f61da 100644 --- a/desktop/internal/i18n/messages.go +++ b/desktop/internal/i18n/messages.go @@ -280,6 +280,10 @@ type GitMessages struct { LoadMore string LoadingCommits string LoadMoreFailed string + // LimitReached ends a log that read count commits, as many as the Git Log settings let it, + // while the history goes on; AdjustLimit opens those settings. + LimitReached func(count int) string + AdjustLimit string // The changed files and the commit details. SelectCommit string diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 23dccd39ab..ab419168e6 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -578,6 +578,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.git.loading": "Loading…", "desktop.git.locateBranch": "Navigate Log to Selected Branch", "desktop.git.log": "Log", + "desktop.git.log.adjustLimit": "Adjust Limit…", + "desktop.git.log.limitReached": "Read {count} commits; older commits are beyond the read limit", "desktop.git.logTab": "Log: {reference}", "desktop.git.longEdges": "Show long graph edges", "desktop.git.noCommits": "No commits yet", @@ -588,9 +590,31 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.git.on": "on {date}", "desktop.git.pathPlaceholder": "Directory or file name", "desktop.git.pathTitle": "Filter by changed path", + "desktop.git.pushAll.defineRemote": "Define remote", + "desktop.git.pushAll.description": "Check the repositories to push, review destinations and commits, then push.", + "desktop.git.pushAll.detachedHead": "Detached HEAD", + "desktop.git.pushAll.emptyRepository": "Empty repository", + "desktop.git.pushAll.failed": "Push failed: {reason}", + "desktop.git.pushAll.filesFailed": "Cannot load changed files: {reason}", + "desktop.git.pushAll.loadingFiles": "Loading changed files…", + "desktop.git.pushAll.noChangedFiles": "This commit has no changed files", + "desktop.git.pushAll.noCommitSelected": "Select a commit to see its changed files", + "desktop.git.pushAll.noRepositories": "No repositories to push", + "desktop.git.pushAll.push": "Push (P)", + "desktop.git.pushAll.pushTags": "Push tags (T)", + "desktop.git.pushAll.pushed": "Pushed", + "desktop.git.pushAll.readFailed": "Cannot read: {reason}", + "desktop.git.pushAll.skipped": "Not pushed: {repository} failed to push", + "desktop.git.pushAll.someFailed": "Some repositories were not pushed; see the Push Commits dialog.", + "desktop.git.pushAll.tagsAll": "All", + "desktop.git.pushAll.tagsCurrentBranch": "Current Branch", + "desktop.git.pushAll.title": "Push Commits", + "desktop.git.pushAll.upToDate": "Up to date", "desktop.git.refreshLog": "Refresh Log", "desktop.git.repo.back": "Back to {name}", + "desktop.git.repo.choose": "Choose Repositories", "desktop.git.repo.current": "Repository: {name}", + "desktop.git.repo.several": "{count} Repositories", "desktop.git.searchUsers": "Search users", "desktop.git.settings.blame": "Show Inline Git Blame", "desktop.git.settings.blameHelp": "Shows the author, age and commit subject of the line the caret is on, after its text. Git is read when a file is saved or HEAD moves; the previous annotation stays until then. Off by default.", @@ -628,6 +652,13 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.git.settings.console.temporaryConfigHelp": "The command line no longer shows the -c settings Lithe passes for a single command, not even folded. The -c arguments the command itself names still show, folded.", "desktop.git.settings.gutter": "Show Git Change Markers", "desktop.git.settings.gutterHelp": "Marks lines added, changed or removed against the Git index in the editor's gutter. Click a marker to see the earlier text, stage that change, or revert it. Markers update when a file is saved and when the Git status changes.", + "desktop.git.settings.logLimitDefault": "{count} (default)", + "desktop.git.settings.logLimitMerged": "Several repositories", + "desktop.git.settings.logLimitMergedHelp": "The most commits read in all while the log merges several chosen repositories by date. The default is 20,000.", + "desktop.git.settings.logLimitSingle": "One repository", + "desktop.git.settings.logLimitSingleHelp": "The most commits read while the log shows one repository. The default is 5,000.", + "desktop.git.settings.logLimits": "Git Log", + "desktop.git.settings.logLimitsHelp": "The most commits the Git Log reads. When it reaches the limit, the end of the log says older commits are beyond the read limit; a higher limit loads more slowly and uses more memory.", "desktop.git.settings.parentReferences": "Show Update Parent Repository References", "desktop.git.settings.parentReferencesHelp": "Shows the option that records the new commits of submodules in their parent repositories. Turned off, the option is hidden and every commit updates the parent references.", "desktop.git.showAll": "Show all references", @@ -1020,10 +1051,11 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.navigation.label": "[Line] [:column]:", "desktop.navigation.title": "Go to Line:Column", "desktop.nested.collapse": "Collapse Repository", - "desktop.nested.commit": "Commit Repository", "desktop.nested.expand": "Expand Repository", "desktop.nested.refUnchanged": "The parent repository's reference to this submodule is unchanged. Commit here, then update the parent to record it.", + "desktop.nested.rootToggle": "Show {name} in the Log", "desktop.nested.roots": "Roots", + "desktop.nested.rootsAll": "Select All", "desktop.newProject.advanced": "Advanced Settings", "desktop.newProject.archiveInvalid": "The downloaded archive is not a valid project.", "desktop.newProject.cancel": "Cancel", @@ -1956,12 +1988,14 @@ var sharedCatalogs = map[string]map[string]string{ "git.log.branchNameClashesWithRemote": "Branch name {name} conflicts with remote branch with the same name", "git.log.branchNameEmpty": "Specify name for the new branch", "git.log.branchNameHead": "HEAD is a reserved keyword", + "git.log.collapse": "Collapse {name}", "git.log.commitDetails": "Commit details", "git.log.commitMessage": "Commit message", "git.log.copyBranchName": "Copy Branch Name", "git.log.copyCommitHash": "Copy Commit Hash", "git.log.copyFailed": "Unable to copy {label}", "git.log.copyShortHash": "Copy Short Hash", + "git.log.expand": "Expand {name}", "git.log.fileCountOne": "{count} file", "git.log.filesCount": "{count} files", "git.log.filterBranch": "Branch", @@ -3314,6 +3348,8 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.git.loading": "正在读取…", "desktop.git.locateBranch": "在日志中定位所选分支", "desktop.git.log": "日志", + "desktop.git.log.adjustLimit": "调整上限…", + "desktop.git.log.limitReached": "已读取 {count} 条提交,更早的提交超出可读取范围", "desktop.git.logTab": "日志: {reference}", "desktop.git.longEdges": "显示长边", "desktop.git.noCommits": "还没有提交", @@ -3324,9 +3360,31 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.git.on": "于 {date}", "desktop.git.pathPlaceholder": "目录或文件名", "desktop.git.pathTitle": "按更改路径筛选", + "desktop.git.pushAll.defineRemote": "定义远程", + "desktop.git.pushAll.description": "勾选要推送的仓库,确认目标和提交后推送。", + "desktop.git.pushAll.detachedHead": "分离 HEAD", + "desktop.git.pushAll.emptyRepository": "空仓库", + "desktop.git.pushAll.failed": "推送失败:{reason}", + "desktop.git.pushAll.filesFailed": "无法加载变更文件:{reason}", + "desktop.git.pushAll.loadingFiles": "正在加载变更文件…", + "desktop.git.pushAll.noChangedFiles": "此提交没有变更文件", + "desktop.git.pushAll.noCommitSelected": "选择一个提交查看变更文件", + "desktop.git.pushAll.noRepositories": "没有可推送的仓库", + "desktop.git.pushAll.push": "推送(P)", + "desktop.git.pushAll.pushTags": "推送标记(T)", + "desktop.git.pushAll.pushed": "已推送", + "desktop.git.pushAll.readFailed": "无法读取:{reason}", + "desktop.git.pushAll.skipped": "未推送:{repository} 推送失败", + "desktop.git.pushAll.someFailed": "有仓库没有推送成功,详情见推送对话框。", + "desktop.git.pushAll.tagsAll": "所有", + "desktop.git.pushAll.tagsCurrentBranch": "当前分支", + "desktop.git.pushAll.title": "推送提交", + "desktop.git.pushAll.upToDate": "已是最新", "desktop.git.refreshLog": "刷新日志", "desktop.git.repo.back": "切回 {name}", + "desktop.git.repo.choose": "选择仓库", "desktop.git.repo.current": "仓库:{name}", + "desktop.git.repo.several": "{count} 个仓库", "desktop.git.searchUsers": "搜索用户", "desktop.git.settings.blame": "显示行尾 Git Blame", "desktop.git.settings.blameHelp": "在光标所在行末尾显示作者、时间和提交标题。仅在保存文件或 HEAD 变化时重新读取 Git,刷新期间保留旧注释。默认关闭。", @@ -3364,6 +3422,13 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.git.settings.console.temporaryConfigHelp": "命令行不再显示 Lithe 为单次命令传入的 -c 配置,折叠后的提示也不显示。命令本身写明的 -c 参数仍折叠显示。", "desktop.git.settings.gutter": "显示 Git 变更标记", "desktop.git.settings.gutterHelp": "在编辑器行号区标出相对 Git 索引新增、修改或删除的行。点击标记可查看修改前的内容、暂存或回退这处修改。保存文件或 Git 状态变化时更新。", + "desktop.git.settings.logLimitDefault": "{count}(默认)", + "desktop.git.settings.logLimitMerged": "多个仓库混排", + "desktop.git.settings.logLimitMergedHelp": "勾选多个仓库按时间混排时,所有仓库合计最多读取的提交数,默认 20000。", + "desktop.git.settings.logLimitSingle": "单个仓库", + "desktop.git.settings.logLimitSingleHelp": "只查看一个仓库时最多读取的提交数,默认 5000。", + "desktop.git.settings.logLimits": "Git 日志", + "desktop.git.settings.logLimitsHelp": "Git 日志最多读取多少条提交。读到上限后,日志末尾会提示更早的提交超出可读取范围;上限越大,加载越慢,占用内存越多。", "desktop.git.settings.parentReferences": "显示更新父仓库引用", "desktop.git.settings.parentReferencesHelp": "显示是否在父仓库中记录子模块新提交的选项。关闭后隐藏该选项,每次提交都会更新父仓库引用。", "desktop.git.showAll": "显示所有引用", @@ -3756,10 +3821,11 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.navigation.label": "[行] [:列]:", "desktop.navigation.title": "跳转到行:列", "desktop.nested.collapse": "折叠仓库", - "desktop.nested.commit": "提交此仓库", "desktop.nested.expand": "展开仓库", "desktop.nested.refUnchanged": "父仓库中该子模块的引用没有变化。在此提交后需要在父仓库中更新引用。", + "desktop.nested.rootToggle": "在日志中显示 {name}", "desktop.nested.roots": "仓库根目录", + "desktop.nested.rootsAll": "全选", "desktop.newProject.advanced": "高级设置", "desktop.newProject.archiveInvalid": "下载的压缩包不是有效的项目。", "desktop.newProject.cancel": "取消", @@ -4692,12 +4758,14 @@ var sharedCatalogs = map[string]map[string]string{ "git.log.branchNameClashesWithRemote": "分支名称 {name} 与同名的远程分支冲突", "git.log.branchNameEmpty": "请指定新分支的名称", "git.log.branchNameHead": "HEAD 是保留关键字", + "git.log.collapse": "折叠 {name}", "git.log.commitDetails": "提交详情", "git.log.commitMessage": "提交说明", "git.log.copyBranchName": "复制分支名称", "git.log.copyCommitHash": "复制提交哈希", "git.log.copyFailed": "无法复制{label}", "git.log.copyShortHash": "复制短哈希", + "git.log.expand": "展开 {name}", "git.log.fileCountOne": "{count} 个文件", "git.log.filesCount": "{count} 个文件", "git.log.filterBranch": "分支", diff --git a/desktop/internal/i18n/zh.go b/desktop/internal/i18n/zh.go index 9d7ed1d94f..717b9db8c6 100644 --- a/desktop/internal/i18n/zh.go +++ b/desktop/internal/i18n/zh.go @@ -81,6 +81,10 @@ var chinese = Messages{ LoadMore: Shared(Chinese, "git.log.loadMore"), LoadingCommits: Shared(Chinese, "git.log.loadingCommits"), LoadMoreFailed: Shared(Chinese, "desktop.git.loadMoreFailed"), + LimitReached: func(count int) string { + return SharedFormat(Chinese, "desktop.git.log.limitReached", map[string]string{"count": strconv.Itoa(count)}) + }, + AdjustLimit: Shared(Chinese, "desktop.git.log.adjustLimit"), SelectCommit: Shared(Chinese, "git.log.selectCommit"), LoadingFiles: Shared(Chinese, "git.log.loadingChangedFiles"), FilesFailed: Shared(Chinese, "desktop.git.filesFailed"), diff --git a/desktop/internal/settingswindow/controller.go b/desktop/internal/settingswindow/controller.go index 49ac55c5e0..6e141eb092 100644 --- a/desktop/internal/settingswindow/controller.go +++ b/desktop/internal/settingswindow/controller.go @@ -94,6 +94,10 @@ type Values struct { // updates the parent repositories' references in the Commit window; both show by default. HideChangeLists bool HideParentReferences bool + // GitLogLimit and GitLogMergedLimit are the most commits the Git Log reads of one repository + // and of several at once, within MinGitLogLimit and MaxGitLogLimit. + GitLogLimit int + GitLogMergedLimit int // GitConsole says which internal Git queries the Git console records and how it draws its // records; the zero value is IntelliJ IDEA's console. GitConsole core.GitConsolePreferences @@ -406,6 +410,9 @@ type Options struct { // Values.HideParentReferences to the settings owner, like SetHideGitGutter. SetHideChangeLists func(bool) SetHideParentReferences func(bool) + // SetGitLogLimits hands a change of Values.GitLogLimit or Values.GitLogMergedLimit to the + // settings owner, like SetHideGitGutter. + SetGitLogLimits func(single, merged int) // SetGitConsole hands a change of Values.GitConsole to the settings owner, like // SetHideGitGutter. SetGitConsole func(core.GitConsolePreferences) diff --git a/desktop/internal/settingswindow/git_log_limits_view.go b/desktop/internal/settingswindow/git_log_limits_view.go new file mode 100644 index 0000000000..2a08cad784 --- /dev/null +++ b/desktop/internal/settingswindow/git_log_limits_view.go @@ -0,0 +1,85 @@ +package settingswindow + +import ( + "slices" + "strconv" + + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/vivaui/viva/ui" +) + +// This file is the Git Log card of the Version Control page (matrix id git-history): the most +// commits the log reads of one repository, and of several merged by date. The log ends there +// and says it reached the limit, with a way back to this card. + +// The Git Log's limits. The defaults are what the log read before they could be changed; Core's +// git.historyPage reads at most MaxGitLogLimit commits of one walk, and git.workspaceHistoryMerge +// and git.graphProjection take as many. +const ( + DefaultGitLogLimit = 5000 + DefaultGitLogMergedLimit = 20000 + MinGitLogLimit = 100 + MaxGitLogLimit = 100000 +) + +var gitLogLimitChoices = []int{1000, 2000, 5000, 10000, 20000, 50000, 100000} + +// ClampGitLogLimit is limit within the card's limits; zero is fallback, the default. +func ClampGitLogLimit(limit, fallback int) int { + if limit == 0 { + return fallback + } + return min(max(limit, MinGitLogLimit), MaxGitLogLimit) +} + +// gitLogLimitsCard declares the Git Log card: a row for each limit, each a list of the choices +// with the default marked, and the stored value among them when it is not one of them. +func (w *window) gitLogLimitsCard(c ui.C, language i18n.Language) { + values := &w.sess.values + single := ClampGitLogLimit(values.GitLogLimit, DefaultGitLogLimit) + merged := ClampGitLogLimit(values.GitLogMergedLimit, DefaultGitLogMergedLimit) + row := func(key, title, help string, value *int, fallback int) bool { + choices := gitLogLimitChoices + if !slices.Contains(choices, *value) { + choices = slices.Sorted(slices.Values(append(slices.Clone(choices), *value))) + } + label := func(n int) string { + if n == fallback { + return i18n.SharedFormat(language, "desktop.git.settings.logLimitDefault", map[string]string{"count": strconv.Itoa(n)}) + } + return strconv.Itoa(n) + } + changed := false + w.settingsRow(c, title, help, func() { + changed = ui.Select(c.Part(key), value, choices, label).Width(selectWidth).Label(title).Changed() + }) + return changed + } + w.card(c, i18n.Shared(language, "desktop.git.settings.logLimits"), i18n.Shared(language, "desktop.git.settings.logLimitsHelp"), func() { + ui.Column(c).FillWidth().Gap(6).Children(func() { + singleChanged := row("logLimit", i18n.Shared(language, "desktop.git.settings.logLimitSingle"), + i18n.Shared(language, "desktop.git.settings.logLimitSingleHelp"), &single, DefaultGitLogLimit) + mergedChanged := row("logMergedLimit", i18n.Shared(language, "desktop.git.settings.logLimitMerged"), + i18n.Shared(language, "desktop.git.settings.logLimitMergedHelp"), &merged, DefaultGitLogMergedLimit) + if singleChanged || mergedChanged { + w.setGitLogLimits(single, merged) + } + }) + }) +} + +// setGitLogLimits stores the Git Log's limits and hands them to the settings owner. +func (w *window) setGitLogLimits(single, merged int) { + if w.sess.finished.Load() { + return + } + single, merged = ClampGitLogLimit(single, DefaultGitLogLimit), ClampGitLogLimit(merged, DefaultGitLogMergedLimit) + values := &w.sess.values + if single == ClampGitLogLimit(values.GitLogLimit, DefaultGitLogLimit) && merged == ClampGitLogLimit(values.GitLogMergedLimit, DefaultGitLogMergedLimit) { + return + } + values.GitLogLimit, values.GitLogMergedLimit = single, merged + if w.ctrl.opts.SetGitLogLimits != nil { + w.ctrl.opts.SetGitLogLimits(single, merged) + } +} diff --git a/desktop/internal/settingswindow/git_log_limits_view_test.go b/desktop/internal/settingswindow/git_log_limits_view_test.go new file mode 100644 index 0000000000..517c953c0c --- /dev/null +++ b/desktop/internal/settingswindow/git_log_limits_view_test.go @@ -0,0 +1,58 @@ +package settingswindow + +import ( + "strconv" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/vivaui/viva/app" +) + +// The Git Log card shows the limits in force, the default marked and a stored limit that is no +// choice of the list among them; a choice reaches the settings owner at once, and Restore Defaults +// brings both defaults back. +func TestGitLogLimitsCardShowsAppliesAndRestores(t *testing.T) { + type limits struct{ single, merged int } + var changes []limits + w := newWindow(NewController(Options{ + SetGitLogLimits: func(single, merged int) { changes = append(changes, limits{single, merged}) }, + }), Values{GitLogMergedLimit: 30000}) + w.sess.page = pageVersionControl + d := openWindow(t, w, func(config *app.Config) { config.Height = 1800 }) + text := func(id string) string { return i18n.Shared(i18n.English, id) } + byDefault := func(n int) string { + return i18n.SharedFormat(i18n.English, "desktop.git.settings.logLimitDefault", map[string]string{"count": strconv.Itoa(n)}) + } + if !d.text(byDefault(DefaultGitLogLimit)) || !d.text("30000") { + t.Fatal("the card does not show the limits in force") + } + + d.click(text("desktop.git.settings.logLimitSingle")) + d.click("10000") + if len(changes) != 1 || changes[0] != (limits{10000, 30000}) || w.sess.values.GitLogLimit != 10000 { + t.Fatalf("changes %+v, window %d, want 10000 handed on with 30000", changes, w.sess.values.GitLogLimit) + } + d.pump() + if !d.text("10000") { + t.Fatal("the card does not show the chosen limit") + } + + d.click("Restore Defaults") + if last := changes[len(changes)-1]; last != (limits{DefaultGitLogLimit, DefaultGitLogMergedLimit}) { + t.Fatalf("Restore Defaults handed on %+v, want both defaults", last) + } + d.pump() + if !d.text(byDefault(DefaultGitLogLimit)) || !d.text(byDefault(DefaultGitLogMergedLimit)) { + t.Fatal("the card does not show the defaults after Restore Defaults") + } +} + +func TestClampGitLogLimitKeepsTheCardsRange(t *testing.T) { + for _, tc := range []struct{ limit, want int }{ + {0, DefaultGitLogLimit}, {1, MinGitLogLimit}, {7000, 7000}, {MaxGitLogLimit + 1, MaxGitLogLimit}, + } { + if got := ClampGitLogLimit(tc.limit, DefaultGitLogLimit); got != tc.want { + t.Fatalf("ClampGitLogLimit(%d) = %d, want %d", tc.limit, got, tc.want) + } + } +} diff --git a/desktop/internal/settingswindow/version_control_view.go b/desktop/internal/settingswindow/version_control_view.go index f9a35e7d98..64887d3fc0 100644 --- a/desktop/internal/settingswindow/version_control_view.go +++ b/desktop/internal/settingswindow/version_control_view.go @@ -6,7 +6,7 @@ import ( ) // versionControlPage is the Version Control page: the GitHub account, then the Git switches of -// the editor, the Commit window and the Git console. Opening the page writes nothing; a switch hands its change to +// the editor, the Commit window, the Git Log's limits and the Git console. Opening the page writes nothing; a switch hands its change to // the settings owner at once. func (w *window) versionControlPage(c ui.C) { language := w.marketLanguage() @@ -44,6 +44,7 @@ func (w *window) versionControlPage(c ui.C) { w.setHideParentReferences(!parents, false) } }) + w.gitLogLimitsCard(c, language) w.gitConsoleCards(c, language) }) } diff --git a/desktop/internal/settingswindow/window_view.go b/desktop/internal/settingswindow/window_view.go index 5888c5d328..2573855dae 100644 --- a/desktop/internal/settingswindow/window_view.go +++ b/desktop/internal/settingswindow/window_view.go @@ -535,6 +535,7 @@ func (w *window) footer(c ui.C) { w.setTerminalBehavior(TerminalBehavior{}, true) w.setFonts(fontprefs.Default(), true) w.setGitConsole(core.GitConsolePreferences{}, true) + w.setGitLogLimits(DefaultGitLogLimit, DefaultGitLogMergedLimit) } ui.Spacer(c) if ui.Button(c, settings.Cancel).Outline().Clicked() { diff --git a/desktop/internal/workbench/app.go b/desktop/internal/workbench/app.go index 3375ca1d27..470809c70e 100644 --- a/desktop/internal/workbench/app.go +++ b/desktop/internal/workbench/app.go @@ -61,7 +61,7 @@ type Kernel interface { ReduceChromeLayout(ctx context.Context, catalog []core.ChromeItem, state core.ChromeLayout, action core.ChromeAction) (core.ChromeLayout, bool, error) GitStatus(ctx context.Context, root string) (core.GitStatus, error) GitReferences(ctx context.Context, root string) (core.GitReferences, error) - GitHistoryPage(ctx context.Context, root, reference, cursor string, limit int) (core.GitHistoryPage, error) + GitHistoryPage(ctx context.Context, root, reference, cursor string, limit, maxCommits int) (core.GitHistoryPage, error) DetectBuildSystems(ctx context.Context, workspaceRoot string, manifests []json.RawMessage) (core.BuildDetection, error) DetectBuildSystemsWithOptions(ctx context.Context, workspaceRoot string, manifests []json.RawMessage, options core.BuildDetectOptions) (core.BuildDetection, error) ResolveStoredBuildOptions(ctx context.Context, document, local json.RawMessage) (core.BuildStoredOptions, error) @@ -304,6 +304,11 @@ type settings struct { // HideParentReferences hides the option that records submodule commits in the parent // repositories; while it is hidden every commit updates them. The option shows by default. HideParentReferences bool `json:"hideParentReferences,omitempty"` + // GitLogLimit and GitLogMergedLimit are the most commits the Git Log reads of one repository + // and of several at once; zero is settingswindow.DefaultGitLogLimit and + // DefaultGitLogMergedLimit (gitlog_limits.go). + GitLogLimit int `json:"gitLogLimit,omitempty"` + GitLogMergedLimit int `json:"gitLogMergedLimit,omitempty"` // GitConsole says which internal Git queries the Git console records and how it draws its // records; the zero value is IntelliJ IDEA's console (gitconsole_settings.go). GitConsole core.GitConsolePreferences `json:"gitConsole,omitzero"` diff --git a/desktop/internal/workbench/changelists_view.go b/desktop/internal/workbench/changelists_view.go index 5045387de9..0287414a28 100644 --- a/desktop/internal/workbench/changelists_view.go +++ b/desktop/internal/workbench/changelists_view.go @@ -93,16 +93,16 @@ func (a *App) drawChangeListSections(c ui.C, p *project) { title += suffix } sc := c.Key("changelist/" + list.ID) - ui.Row(sc).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).Gap(6).PadX(8).Children(func() { + ui.Row(sc).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).Gap(changeTreeGap).PadX(8).Children(func() { all := allStaged(changes) - if ui.Checkbox(sc, &all, "").Label(title).Disabled(busy || !hasToggleable(changes)).Clicked() { + if a.treeCheckbox(sc, &all, title).Disabled(busy || !hasToggleable(changes)).Clicked() { sc.After(func() { a.stageChanges(p, changes, surfaceButton) }) } ui.Text(sc, title).Weight(gfx.WeightMedium).Ellipsis().Shrink(1) ui.Text(sc, t.Files(fileCount(changes))).Muted().Shrink(0) }) for _, change := range changes { - a.drawCommitChange(c, p, change, changeRowIndent) + a.drawCommitChange(c, p, change, a.changeRowIndent()) } } }) diff --git a/desktop/internal/workbench/commit.go b/desktop/internal/workbench/commit.go index 6c061c0aff..c973a67fef 100644 --- a/desktop/internal/workbench/commit.go +++ b/desktop/internal/workbench/commit.go @@ -54,6 +54,9 @@ type commitState struct { // attempt is the session of the last run, kept while its results are shown; nil when // there are none. attempt *core.WorkspaceCommitSession + // pushAfter is set by Commit and Push while its commit runs or waits for a retry: once the + // commit succeeds, the Push Commits dialog opens on the repositories it committed. + pushAfter bool // ai is the AI message generation of the commit area (aicommit.go). ai aiCommitState } @@ -123,8 +126,6 @@ type commitTarget struct { // console says a run shows the Console tab of the Git tool window: the commit is the // Commit tool window's, outside the Git tool window. console bool - // repoID is the workspace ID of the repository the commit plans; empty for the project's own. - repoID string } // projectCommit is the commit of the project's repository, held to the active ChangeList. @@ -151,21 +152,13 @@ func (t commitTarget) repositoryName(id string) string { return id } -// workspaceID is the ID the target's repository has in a workspace commit. -func (t commitTarget) workspaceID() string { - if t.repoID != "" { - return t.repoID - } - return commitRepositoryID -} - // request is the request that plans a commit of the staged changes of the target with the // message typed, pushed afterwards when push is set. A retry leaves the scope out: Core keeps // the scope of the run it continues. func (t commitTarget) request(push bool) core.WorkspaceCommitRequest { c := t.state return core.WorkspaceCommitRequest{ - Repositories: []core.WorkspaceCommitRepository{{ID: t.workspaceID(), Root: t.root}}, + Repositories: []core.WorkspaceCommitRepository{{ID: commitRepositoryID, Root: t.root}}, Message: c.message(), Amend: c.amend, Author: c.authorText(), @@ -239,13 +232,18 @@ func (a *App) startCommitIn(p *project, t commitTarget, push bool, surface actio action = "git.commitAndPush" } a.performed(action, surface) - request := a.commitRequest(t, push) + // As in IDEA, Commit and Push commits first and then asks which repositories to push in + // the Push Commits dialog. A kernel without that dialog pushes through the commit session, + // whose plan the macOS client always shows before anything runs. + _, dialog := a.workspacePusher() + c.pushAfter = push && dialog + request := a.commitRequest(t, push && !dialog) if request.Message == "" { + c.pushAfter = false a.notify(a.text.Commit.EnterMessage) return } - // The macOS client always shows the plan of a push before anything runs. - a.prepareCommit(p, t, request, push) + a.prepareCommit(p, t, request, push && !dialog) } // retryCommit plans the rest of the last run in the checkout of t and shows it for review. @@ -275,6 +273,7 @@ func (a *App) prepareCommit(p *project, t commitTarget, request core.WorkspaceCo return func(a *App) { c.busy = false if err != nil { + c.pushAfter = false a.commitFailed(err) return } @@ -340,7 +339,7 @@ func (a *App) confirmReview(p *project, t commitTarget) { } // cancelReview closes the review of c without running anything. -func (a *App) cancelReview(c *commitState) { c.review = nil } +func (a *App) cancelReview(c *commitState) { c.review, c.pushAfter = nil, false } // runCommit steps session until it finishes, then reads the checkout again and reports how // the run ended. The steps run one after another in one background task: each is a commit or @@ -366,14 +365,39 @@ func (a *App) runCommit(p *project, t commitTarget, session core.WorkspaceCommit c.busy = false t.written(a) if err != nil { + c.pushAfter = false a.commitFailed(err) return } a.commitFinished(c, session) + if session.Succeeded && c.pushAfter { + c.pushAfter = false + a.pushCommitted(p, t, session) + } } }) } +// pushCommitted opens the Push Commits dialog after Commit and Push on every repository the +// commit bound, with the ones it committed checked. +func (a *App) pushCommitted(p *project, t commitTarget, session core.WorkspaceCommitSession) { + bindings := session.Repositories + if len(bindings) == 0 { + bindings = []core.WorkspaceCommitRepository{{ID: commitRepositoryID, Root: t.root}} + } + names := make(map[string]string, len(bindings)) + for _, binding := range bindings { + names[binding.ID] = t.repositoryName(binding.ID) + } + committed := map[string]bool{} + for id, result := range session.Results { + if result.Committed { + committed[id] = true + } + } + a.openWorkspacePush(p, bindings, names, committed, surfaceButton) +} + // commitFinished reports the end of a run. A run that succeeded clears the message, amend and // the author; one that did not keeps its results, and a retry while it can continue. func (a *App) commitFinished(c *commitState, session core.WorkspaceCommitSession) { @@ -414,7 +438,7 @@ func incompleteRun(session core.WorkspaceCommitSession) error { } // dismissResults forgets the results of the last run of c. -func (a *App) dismissResults(c *commitState) { c.attempt = nil } +func (a *App) dismissResults(c *commitState) { c.attempt, c.pushAfter = nil, false } // commitFailed reports a commit the kernel refused or could not run. func (a *App) commitFailed(err error) { diff --git a/desktop/internal/workbench/commit_test.go b/desktop/internal/workbench/commit_test.go index 8f446c0ad7..6cfb5b313f 100644 --- a/desktop/internal/workbench/commit_test.go +++ b/desktop/internal/workbench/commit_test.go @@ -194,29 +194,6 @@ func TestCommitButtonCommitsTheStagedChanges(t *testing.T) { } } -func TestCommitAndPushShowsTheReviewFirst(t *testing.T) { - dir := newTestRepository(t) - h := newHarness(t, &gitKernel{Client: core.NewClient()}) - p := h.openCommit(dir) - h.stageAll(p) - p.commit.editor.Insert("Publish the change") - h.settle() - - h.clickNamed(h.app.text.Commit.CommitAndPush) - h.settle() - if p.commit.review == nil { - t.Fatal("commit and push ran without showing the review") - } - if got := gitRun(t, dir, "log", "-1", "--format=%s"); got != "initial" { - t.Fatalf("last commit before the review was confirmed = %q, want initial", got) - } - - h.clickNamed(h.app.text.Commit.Cancel) - if p.commit.review != nil { - t.Fatal("cancel left the review open") - } -} - func TestCommitWithoutAMessageAsksForOne(t *testing.T) { dir := newTestRepository(t) h := newHarness(t, &gitKernel{Client: core.NewClient()}) @@ -315,10 +292,11 @@ func TestCommitReviewNamesTheAuthorAndTheSignOff(t *testing.T) { p.commit.signOff = true h.settle() - h.clickNamed(h.app.text.Commit.CommitAndPush) - if p.commit.review == nil { - t.Fatal("commit and push ran without showing the review") - } + // Commit and Push asks in the Push Commits dialog afterwards; a retry is what always shows + // the review first. + target := p.projectCommit() + h.app.prepareCommit(p, target, h.app.commitRequest(target, false), true) + h.await("the review", func() bool { return !p.commit.busy && p.commit.review != nil }) text := h.app.text.Commit if !h.shows(text.AuthorLine("Pair Author ")) || !h.shows(text.SignOffNote) { t.Fatal("the review does not name the author and the sign-off") diff --git a/desktop/internal/workbench/commit_view.go b/desktop/internal/workbench/commit_view.go index 5e596316ef..34e0201ed3 100644 --- a/desktop/internal/workbench/commit_view.go +++ b/desktop/internal/workbench/commit_view.go @@ -26,14 +26,45 @@ const ( // commitReviewHeight is the most the steps of a review take before they scroll. const commitReviewHeight = 320 -// The left padding of a change row, so its checkbox sits one logIndent right of its parent's, as -// the levels of IDEA's change tree do. changeRowIndent is for a change right under the change -// list, whose checkbox is at 8; repositoryChangeIndent for a change under a repository's group, -// whose checkbox follows the group's fold button (drawRepositoryGroup). -const ( - changeRowIndent = 8 + logIndent - repositoryChangeIndent = 8 + shellHideSize + repositoryGroupGap + logIndent -) +// changeTreeGap is the space between the parts of a line of the change tree. +const changeTreeGap = 6 + +// The change tree lines its rows up on one grid, as IDEA's does. A level is a checkbox and the +// gap after it to the right of its parent, so a row's checkbox sits under its parent's name, or +// under the color of its repository. A fold has a slot of a checkbox with a gap on either side +// before the row's checkbox, so the fold of a row is centered under its parent's checkbox; a row +// without a fold among rows with one keeps the slot empty. The first level starts at 8. + +// changeTreeLevel is how much further right a level of the change tree starts than its parent. +func (a *App) changeTreeLevel() float32 { return components.CheckboxExtent(a.theme) + changeTreeGap } + +// changeTreeSlot is the width of the slot of a fold of the change tree. +func (a *App) changeTreeSlot() float32 { + return components.CheckboxExtent(a.theme) + 2*changeTreeGap +} + +// changeRowIndent is the left padding of a change right under a change list whose line has no +// fold: its checkbox is under the list's title. +func (a *App) changeRowIndent() float32 { return 8 + a.changeTreeLevel() } + +// repositoryChangeIndent is the left padding of a change under a repository's group, two levels +// under the change list's line, past the empty slot of a fold: its checkbox is under the color +// of its repository (drawRepositoryGroup). +func (a *App) repositoryChangeIndent() float32 { + return 8 + 2*a.changeTreeLevel() + a.changeTreeSlot() +} + +// drawChangeTreeFold declares the fold of a line of the change tree in its slot, named collapse +// while the line is open and expand while it is folded, and reports a click. +func (a *App) drawChangeTreeFold(c ui.C, folded bool, collapse, expand string) bool { + chevron, label := icons.ChevronDown, collapse + if folded { + chevron, label = icons.ChevronRight, expand + } + side := a.changeTreeSlot() + return ui.Button(c, label).Icon(chevron).IconOnly().Ghost().Size(side, min(side, logItemHeight)).Shrink(0). + Tooltip(label).Clicked() +} // commitPageView declares the body of the Commit tool window. func (a *App) commitPageView(c ui.C) { @@ -136,7 +167,7 @@ func (a *App) drawCommitChanges(c ui.C, p *project) ui.Box { } a.drawChangeRows(c, t.ChangeList, t.Files(fileCount(changes)), changes, cs.busy, func() { a.stageAll(p, surfaceButton) }, - func(change core.GitChange) { a.drawCommitChange(c, p, change, changeRowIndent) }) + func(change core.GitChange) { a.drawCommitChange(c, p, change, a.changeRowIndent()) }) }) } @@ -161,7 +192,7 @@ func (a *App) drawCommitChange(c ui.C, p *project, change core.GitChange, indent // unstages them all, with the list's title and size, over a row per change. func (a *App) drawChangeRows(c ui.C, title, size string, changes []core.GitChange, busy bool, toggleAll func(), row func(core.GitChange)) { ui.Scroll(c).Scrollbars().Grow(1).FillWidth().PadY(4).Children(func() { - a.drawChangeListHeader(c, title, size, allStaged(changes), hasToggleable(changes), busy, toggleAll) + a.drawChangeListHeader(c, title, size, allStaged(changes), hasToggleable(changes), busy, nil, toggleAll) for _, change := range changes { row(change) } @@ -170,17 +201,36 @@ func (a *App) drawChangeRows(c ui.C, title, size string, changes []core.GitChang // drawChangeListHeader declares the line over a change list: the checkbox that stages or unstages // all of its changes, checked when all is set and enabled when toggleable is, with the list's title -// and size. -func (a *App) drawChangeListHeader(c ui.C, title, size string, all, toggleable, busy bool, toggleAll func()) { - ui.Row(c).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).Gap(6).PadX(8).Children(func() { - if ui.Checkbox(c, &all, "").Label(title).Disabled(busy || !toggleable).Clicked() { - c.After(toggleAll) +// and size. With folded, the line starts with the fold of the list, which flips it. +func (a *App) drawChangeListHeader(c ui.C, title, size string, all, toggleable, busy bool, folded *bool, toggleAll func()) { + ui.Row(c).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).PadX(8).Children(func() { + if folded != nil { + lang := a.language() + collapse := i18n.SharedFormat(lang, "git.log.collapse", map[string]string{"name": title}) + expand := i18n.SharedFormat(lang, "git.log.expand", map[string]string{"name": title}) + if a.drawChangeTreeFold(c.Key("changelist-fold"), *folded, collapse, expand) { + c.After(func() { *folded = !*folded }) + } } - ui.Text(c, title).Weight(gfx.WeightMedium).Ellipsis().Shrink(1) - ui.Text(c, size).Muted().Shrink(0) + ui.Row(c).Grow(1).Shrink(1).Items(ui.Center).Gap(changeTreeGap).Children(func() { + if a.treeCheckbox(c, &all, title).Disabled(busy || !toggleable).Clicked() { + c.After(toggleAll) + } + ui.Text(c, title).Weight(gfx.WeightMedium).Ellipsis().Shrink(1) + ui.Text(c, size).Muted().Shrink(0) + }) }) } +// treeCheckbox is the checkbox of a line of the change tree, named label for assistive +// technology. It is laid out no wider than its square, so it sits as close to the fold before it +// and to the name after it as the checkboxes of IDEA's change tree do; Viva still declares the +// enlarged region around the square that a click hits. +func (a *App) treeCheckbox(c ui.C, value *bool, label string) ui.Box { + side := components.CheckboxExtent(a.theme) + return ui.Checkbox(c, value, "").Label(label).Size(side, side).Shrink(0) +} + // drawChangeRow declares the row of one change: its checkbox, its icon, its name and folder, // and whether it is staged, indent from the left, with the context menu menu builds. It reports a // click on the checkbox and a double click on the row. @@ -200,7 +250,7 @@ func (a *App) drawChangeRow(c ui.C, change core.GitChange, busy, selected bool, name = path.Base(change.OriginalPath) + " → " + name } rowC := c.Key(change.Path) - row := ui.Row(rowC).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).Gap(6). + row := ui.Row(rowC).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).Gap(changeTreeGap). PadSides(0, 8, 0, indent).Hover(ui.Look{}.Background(a.colors.Hover)). HitWith(ui.ID(rowC), change.Path, gfx.HitOptions{Cursor: gfx.PointerCursorHand}) if selected { @@ -209,7 +259,7 @@ func (a *App) drawChangeRow(c ui.C, change core.GitChange, busy, selected bool, ui.ContextMenu(rowC, row, menu(rowC)) row.Children(func() { staged := change.Staged - toggled = ui.Checkbox(c, &staged, "").Label(label).Disabled(busy || !change.CanToggleStaging).Clicked() + toggled = a.treeCheckbox(c, &staged, label).Disabled(busy || !change.CanToggleStaging).Clicked() icon := fileicons.ForFile(path.Base(change.Path), a.colors.Dark) if folder { icon = fileicons.ForDirectory(path.Base(strings.TrimSuffix(change.Path, "/")), a.colors.Dark) diff --git a/desktop/internal/workbench/difftab.go b/desktop/internal/workbench/difftab.go index b8098a460b..07c3b97641 100644 --- a/desktop/internal/workbench/difftab.go +++ b/desktop/internal/workbench/difftab.go @@ -268,7 +268,7 @@ func (a *App) openCommitDiff(p *project, root, commit string, file core.GitCommi return nil } var files []core.GitChange - if p.log.selected == commit { + if _, selected := p.logCommitAt(p.log.selected); p.log.selected != "" && selected == commit { for _, f := range p.log.files { files = append(files, core.GitChange{Path: f.Path, Status: f.Status}) } diff --git a/desktop/internal/workbench/git_history.go b/desktop/internal/workbench/git_history.go index 4c0330baa2..f47a4963b0 100644 --- a/desktop/internal/workbench/git_history.go +++ b/desktop/internal/workbench/git_history.go @@ -142,13 +142,32 @@ func (a *App) logMenuRevisions(p *project, row int) []string { return revisions } -// historyHints are Core's hints for the commit menu of revisions in the repository the log walks. -// The first call for a selection asks for them and reports nothing ready; the menu is painted -// again when they arrive. A failed request offers every action, and the action's own preview or -// write decides. -func (a *App) historyHints(p *project, revisions []string) (core.HistoryActionCapabilities, bool) { +// logMenuTarget is the repository root the commit menu of log row acts in and the commits it acts +// on, as their keys in the list and their hashes. While the log walks several repositories it acts +// in the repository of the row's commit, on the chosen commits of that repository only, since a +// Git operation runs in one repository. +func (a *App) logMenuTarget(p *project, row int) (root string, keys, hashes []string) { + keys = a.logMenuRevisions(p, row) + l := &p.log + if len(keys) == 0 || l.origins == nil { + return p.logRepositoryRoot(), keys, keys + } + root, _ = p.logCommitAt(l.graph.Rows[row].CommitHash) + mine := keys[:0:0] + for _, key := range keys { + if at, hash := p.logCommitAt(key); at == root { + mine, hashes = append(mine, key), append(hashes, hash) + } + } + return root, mine, hashes +} + +// historyHints are Core's hints for the commit menu of revisions in the repository at root. The +// first call for a selection asks for them and reports nothing ready; the menu is painted again +// when they arrive. A failed request offers every action, and the action's own preview or write +// decides. +func (a *App) historyHints(p *project, root string, revisions []string) (core.HistoryActionCapabilities, bool) { h := &p.gitHistory - root := p.logRepositoryRoot() key := root + "\x00" + strconv.Itoa(p.log.gen) + "\x00" + strings.Join(revisions, ",") if h.hintsKey == key { return h.hints, h.hintsReady @@ -198,16 +217,21 @@ func (a *App) copyRevisions(revisions []string, short bool, label string) { } } -// beginTagAt opens the New Tag dialog on the commit revision of the repository the log walks. -func (a *App) beginTagAt(p *project, revision string) { +// beginTagAt opens the New Tag dialog on the commit revision of the repository at root. +func (a *App) beginTagAt(p *project, root, revision string) { a.adoptLogBranches(p) + if root != p.logRepositoryRoot() { + // A commit of another repository the log walks with it: the dialog writes the tag there. + a.branch.repo, a.branch.refs = p.logBranchRepoAt(root), p.referencesAt(root) + } a.beginCreateTag(p) a.branch.target = core.GitReference{FullName: revision, ShortName: shortHash(revision)} } -// beginHistoryRewrite opens the dialog of the rewrite operation of revisions and reads its preview. -func (a *App) beginHistoryRewrite(p *project, operation string, revisions []string) { - a.reviewHistoryRewrite(p, operation, revisions, p.logRepositoryRoot()) +// beginHistoryRewrite opens the dialog of the rewrite operation of revisions in the repository at +// root and reads its preview. +func (a *App) beginHistoryRewrite(p *project, operation, root string, revisions []string) { + a.reviewHistoryRewrite(p, operation, revisions, root) a.performed("git.history."+operation, surfaceContextMenu) } @@ -382,13 +406,12 @@ func (a *App) copyRecoveryReference(p *project) { } // beginCherryPick opens the dialog that confirms the cherry-pick or the revert, as operation -// says, of the commit revision in the repository the log walks. -func (a *App) beginCherryPick(p *project, operation, revision string) { +// says, of the commit revision with subject in the repository at root. +func (a *App) beginCherryPick(p *project, operation, root, revision, subject string) { if _, ok := a.kernel.(historyKernel); !ok { return } - commit, _ := p.log.commit(revision) - p.gitHistory.confirm = historyConfirmState{open: true, operation: operation, revision: revision, subject: commit.Subject, root: p.logRepositoryRoot()} + p.gitHistory.confirm = historyConfirmState{open: true, operation: operation, revision: revision, subject: subject, root: root} } // runCherryPick applies the change of the confirmed commit on the current branch, or reverts it, @@ -444,12 +467,13 @@ func historyPathList(paths []string) string { return strings.Join(paths[:shown], ", ") + ", …" } -// beginHistoryReset opens the reset dialog on revision, with the mixed mode Git takes by default. -func (a *App) beginHistoryReset(p *project, revision string) { +// beginHistoryReset opens the reset dialog on revision in the repository at root, with the mixed +// mode Git takes by default. +func (a *App) beginHistoryReset(p *project, root, revision string) { if _, ok := a.kernel.(historyKernel); !ok { return } - p.gitHistory.reset = historyResetState{open: true, revision: revision, root: p.logRepositoryRoot(), mode: core.GitResetMixed} + p.gitHistory.reset = historyResetState{open: true, revision: revision, root: root, mode: core.GitResetMixed} } // runHistoryReset moves the current branch to the commit of the reset dialog in its mode. diff --git a/desktop/internal/workbench/git_history_view.go b/desktop/internal/workbench/git_history_view.go index 89549ead0c..40f8f17b47 100644 --- a/desktop/internal/workbench/git_history_view.go +++ b/desktop/internal/workbench/git_history_view.go @@ -29,19 +29,20 @@ func historyRewriteMenuText(lang i18n.Language, operation string) string { } } -// logCommitMenu declares the commit menu of log row: copying the hashes of the commits it acts -// on, a tag, a cherry-pick, a revert or a reset at one commit, the reviewed rewrites, and Rebase +// logCommitMenu declares the commit menu of log row, in the repository of the row's commit +// (logMenuTarget): copying the hashes of the commits it acts on, a tag, a cherry-pick, a revert or a reset at one commit, the reviewed rewrites, and Rebase // from Here. Core's hints only grey out what cannot fit the selection; the dialogs decide. func (a *App) logCommitMenu(p *project, row int) func(*ui.MenuItems) { return func(menu *ui.MenuItems) { - revisions := a.logMenuRevisions(p, row) + root, keys, revisions := a.logMenuTarget(p, row) if len(revisions) == 0 { return } lang := a.language() single, revision := len(revisions) == 1, revisions[0] + commit, _ := p.log.commit(keys[0]) busy := p.historyBusy() - hints, ready := a.historyHints(p, revisions) + hints, ready := a.historyHints(p, root, revisions) for _, short := range []bool{false, true} { label := i18n.Shared(lang, "git.log.copyCommitHash") if short { @@ -53,17 +54,17 @@ func (a *App) logCommitMenu(p *project, row int) func(*ui.MenuItems) { } menu.Separator() if menu.Item(i18n.Shared(lang, "git.log.newTag")).Disabled(!single).Clicked() { - a.beginTagAt(p, revision) + a.beginTagAt(p, root, revision) } // Until the hints arrive a cherry-pick stays offered, as its preflight still decides. if menu.Item(i18n.Shared(lang, "native.cherryPickCommit")).Disabled(!single || busy || ready && !hints.CanCherryPick).Clicked() { - a.beginCherryPick(p, gitOperationCherryPick, revision) + a.beginCherryPick(p, gitOperationCherryPick, root, revision, commit.Subject) } if menu.Item(i18n.Shared(lang, "native.revertCommit")).Disabled(!single || busy).Clicked() { - a.beginCherryPick(p, gitOperationRevert, revision) + a.beginCherryPick(p, gitOperationRevert, root, revision, commit.Subject) } if menu.Item(i18n.Shared(lang, "native.resetCurrentBranchToHere")).Disabled(!single || busy).Clicked() { - a.beginHistoryReset(p, revision) + a.beginHistoryReset(p, root, revision) } menu.Separator() for _, operation := range historyRewriteMenuOperations { @@ -72,12 +73,12 @@ func (a *App) logCommitMenu(p *project, row int) func(*ui.MenuItems) { item = item.Destructive() } if item.Disabled(busy || !historyRewriteFits(operation, single, ready, hints)).Clicked() { - a.beginHistoryRewrite(p, operation, revisions) + a.beginHistoryRewrite(p, operation, root, revisions) } } if menu.Item(i18n.Shared(lang, "desktop.rebase.fromHere")).Disabled(!single || busy).Clicked() { - // The rebase works in the repository the log walks, nested or the project's own. - a.beginRebaseFromHere(p, revision, "") + // The rebase works in the repository of the commit, nested or the project's own. + a.beginRebaseFromHere(p, root, revision, "") } } } diff --git a/desktop/internal/workbench/git_log_repo.go b/desktop/internal/workbench/git_log_repo.go index 4df09e42ea..a24e53a78a 100644 --- a/desktop/internal/workbench/git_log_repo.go +++ b/desktop/internal/workbench/git_log_repo.go @@ -3,6 +3,7 @@ package workbench import ( "context" "path/filepath" + "slices" "github.com/1lck/Lithe-IDEA/desktop/internal/core" ) @@ -13,7 +14,8 @@ import ( // itself walks its first nested repository. A click on a root of the Paths filter, or on a group or // a reference of another repository in the reference pane, picks that repository: its history, // commit details, comparisons, fetches and branch writes then act on it, and the log's header names -// it. The other repositories' references are read in nested_refs.go. +// it. The roots list chooses several repositories too, and the log then shows their commits +// together (gitlog_multi.go). The other repositories' references are read in nested_refs.go. // logRepo is the nested repository the log walks, nil while it walks the project's own. func (p *project) logRepo() *nestedRepo { @@ -79,6 +81,10 @@ func (p *project) repositoryName(id string) string { // or picks a nested one because the folder is no repository, the log walks that one from its start. func (a *App) selectLogRepo(p *project) { n := &p.nested + if p.walksSeveral() { + a.selectLogRepos(p) + return + } selection, ok := a.workspaceSelection(p, n.logRepo) if !ok { return @@ -111,12 +117,12 @@ func (a *App) setLogRepo(p *project, id, full, short string) { if p.isOwnID(id) { id = "" } - if p.nested.logRepo == id && full == "" { + if p.nested.logRepo == id && full == "" && !p.walksSeveral() { return } // The history walk belongs to the repository it was opened in, so it is closed before the switch. a.releaseLogCursor(p) - p.nested.logRepo = id + p.nested.logRepo, p.nested.chosen = id, nil if selection, ok := a.workspaceSelection(p, id); ok { p.nested.others = selection.Others } @@ -148,11 +154,36 @@ func (a *App) workspaceSelection(p *project, picked string) (core.WorkspaceRepos return selection, true } -// releaseLogCursor closes the history walk of the log, when one is open, in the repository it -// was opened in. +// selectLogRepos asks Core which of the repositories the log walks together are still listed once +// the repositories were read again. When some are gone the log walks the ones left, or the one Core +// falls back to, from its start. +func (a *App) selectLogRepos(p *project) { + n := &p.nested + selection, ok := a.workspaceRepositories(p, n.chosen) + if !ok { + return + } + if !slices.Equal(selection.Chosen, n.chosen) { + a.applyLogRepos(p, selection) + if p.log.started { + a.loadLog(p) + } + return + } + n.others = selection.Others + if p.log.started { + a.loadNestedReferences(p) + } +} + +// releaseLogCursor closes the history walks of the log, when they are open, in the repositories +// they were opened in. func (a *App) releaseLogCursor(p *project) { - if p.log.cursor != "" { - a.closeLogCursor(p, p.log.cursor) - p.log.cursor = "" + l := &p.log + if l.cursor != "" { + a.closeLogCursor(p, l.cursor) + l.cursor = "" } + a.closeWalkCursors(p, l.walks) + l.walks, l.origins, l.pending = nil, nil, nil } diff --git a/desktop/internal/workbench/git_rebase.go b/desktop/internal/workbench/git_rebase.go index 46f7dc33ed..a936c7cd98 100644 --- a/desktop/internal/workbench/git_rebase.go +++ b/desktop/internal/workbench/git_rebase.go @@ -80,8 +80,9 @@ func rebaseDone(status string) bool { return status == "completed" || status == "aborted" } -// beginRebaseFromHere opens the rebase dialog on the commits after base and reads their preview. -func (a *App) beginRebaseFromHere(p *project, base, subject string) { +// beginRebaseFromHere opens the rebase dialog on the commits after base in the repository at root +// and reads their preview. +func (a *App) beginRebaseFromHere(p *project, root, base, subject string) { if _, ok := a.kernel.(rebaseKernel); !ok { return } @@ -94,7 +95,6 @@ func (a *App) beginRebaseFromHere(p *project, base, subject string) { r := &p.rebase r.gen++ gen := r.gen - root := p.logRepositoryRoot() *r = rebaseState{open: true, gen: gen, busy: true, base: base, subject: subject, session: r.session, root: root} kernel := a.kernel.(rebaseKernel) a.performed("git.rebase.fromHere", surfaceContextMenu) diff --git a/desktop/internal/workbench/gitgraph.go b/desktop/internal/workbench/gitgraph.go index f6641db6f1..693f21327a 100644 --- a/desktop/internal/workbench/gitgraph.go +++ b/desktop/internal/workbench/gitgraph.go @@ -398,9 +398,9 @@ func (a *App) paintLogRow(canvas *gfx.Canvas, rect gfx.Rect, index int) { commit, _ := l.commit(row.CommitHash) selected := row.CommitHash == l.selected a.paintGraphRow(canvas, m, rect, row, color) - if slot, ok := a.project.repositorySlot(a.project.logRepoID()); ok && a.project.workspaceMode() { + if slot, ok := a.project.repositorySlot(a.project.logCommitRepo(row.CommitHash)); ok && a.project.workspaceMode() { // As IDEA marks each commit with the color of its root, the strip at the left edge says which - // repository of the folder the log walks. + // repository of the folder the commit belongs to, also while the log walks several at once. canvas.Fill(gfx.Rect{X: rect.X, Y: rect.Y, Width: logRootStripWidth, Height: rect.Height}, repositoryColor(slot, dark)) } diff --git a/desktop/internal/workbench/gitlog.go b/desktop/internal/workbench/gitlog.go index 69d6106ee0..410166d459 100644 --- a/desktop/internal/workbench/gitlog.go +++ b/desktop/internal/workbench/gitlog.go @@ -73,6 +73,9 @@ const ( // logPopoverViewMore is the overflow menu of the filter bar: the view buttons it has no room // for. logPopoverViewMore + // logPopoverRoots is the list of the repositories of the project folder under the name of the + // one the log walks, after the filter chips. + logPopoverRoots ) // logSection is one section of the reference pane: the local branches, the remote ones @@ -106,12 +109,23 @@ type gitLogState struct { referenceLabel string commits []core.GitCommit + // byHash finds a loaded commit by the key the graph knows it by: its hash, or the merged key + // while the log walks several repositories. byHash map[string]int cursor string hasMore bool + // walks are the repositories the log walks while it walks several, origins where each of the + // commits comes from and pending the walks whose next page the list waits on; all nil while + // the log walks one repository (gitlog_multi.go). + walks []logWalk + origins []logOrigin + pending []int // loadingMore and moreFailed are the state of the next page. loadingMore bool moreFailed bool + // limitReached says the log read as many commits as the Git Log settings let it while the + // history goes on; the list ends there with a note offering the settings (gitlog_limits.go). + limitReached bool // window is the wider history the graph's lanes and colors stay stable against. window []core.GraphCommit @@ -212,6 +226,7 @@ func (a *App) loadLog(p *project) { if l.cursor != "" { a.closeLogCursor(p, l.cursor) } + a.closeWalkCursors(p, l.walks) l.gen++ gen := l.gen // A projection still running for the old commits must not land on the new ones. @@ -222,7 +237,8 @@ func (a *App) loadLog(p *project) { } l.loading, l.err = true, nil l.commits, l.byHash, l.cursor, l.hasMore = nil, nil, "", false - l.loadingMore, l.moreFailed, l.window = false, false, nil + l.walks, l.origins, l.pending = nil, nil, nil + l.loadingMore, l.moreFailed, l.limitReached, l.window = false, false, false, nil l.graph, l.currentRows = core.Graph{}, nil l.pathFiles = nil // The upstreams the graph paints were read for the repository before this one. @@ -230,14 +246,18 @@ func (a *App) loadLog(p *project) { a.selectCommit(p, "") // The nested repositories' groups in the reference pane are read with the log (nested_refs.go). a.loadNestedReferences(p) + if p.walksSeveral() { + a.loadLogRepos(p, gen) + return + } kernel, root, reference := a.kernel, p.logRoot(), l.reference - expanded := l.expanded + expanded, limit := l.expanded, a.gitLogLimit() a.background(p, gitTimeout, func(ctx context.Context) func(*App) { refs, sections, current, err := readReferences(ctx, kernel, root) var page core.GitHistoryPage var graph core.Graph if err == nil { - page, err = kernel.GitHistoryPage(ctx, root, reference, "", logPageSize) + page, err = kernel.GitHistoryPage(ctx, root, reference, "", min(logPageSize, limit), limit) } if err == nil { commits := graphCommits(page.Commits) @@ -263,7 +283,7 @@ func (a *App) loadLog(p *project) { l.refs, l.sections, l.current = refs, sections, current l.commits = page.Commits l.byHash = indexCommits(page.Commits) - l.cursor, l.hasMore = page.NextCursor, page.HasMore + l.cursor, l.hasMore, l.limitReached = page.NextCursor, page.HasMore, page.LimitReached l.setGraph(graph) if l.filtered() { a.reproject(p, 0) @@ -317,11 +337,13 @@ func readReferences(ctx context.Context, kernel Kernel, root string) (core.GitRe return refs, sections, current, nil } -// loadLogWindow reads the wider history window and lays the graph out again against it. +// loadLogWindow reads the wider history window, no wider than the log reads, and lays the +// graph out again against it. func (a *App) loadLogWindow(p *project, gen int) { kernel, root, reference := a.kernel, p.logRoot(), p.log.reference + size := min(logWindowSize, a.gitLogLimit()) a.background(p, gitTimeout, func(ctx context.Context) func(*App) { - page, err := kernel.GitHistoryPage(ctx, root, reference, "", logWindowSize) + page, err := kernel.GitHistoryPage(ctx, root, reference, "", size, size) if err == nil && page.NextCursor != "" { _, _ = kernel.CloseGitHistoryCursor(ctx, root, page.NextCursor) } @@ -342,6 +364,10 @@ func (a *App) loadLogWindow(p *project, gen int) { // loadMoreLog reads the next page of history when there is one and none is on its way. func (a *App) loadMoreLog(p *project) { l := &p.log + if l.walks != nil { + a.loadMoreLogRepos(p) + return + } if l.loading || !l.hasMore || l.loadingMore || l.moreFailed || l.cursor == "" { return } @@ -349,7 +375,7 @@ func (a *App) loadMoreLog(p *project) { gen := l.gen kernel, root, reference, cursor := a.kernel, p.logRoot(), l.reference, l.cursor a.background(p, gitTimeout, func(ctx context.Context) func(*App) { - page, err := kernel.GitHistoryPage(ctx, root, reference, cursor, logPageSize) + page, err := kernel.GitHistoryPage(ctx, root, reference, cursor, logPageSize, 0) return func(a *App) { if l.gen != gen { return @@ -361,7 +387,7 @@ func (a *App) loadMoreLog(p *project) { } l.commits = slices.Concat(l.commits, page.Commits) l.byHash = indexCommits(l.commits) - l.cursor, l.hasMore = page.NextCursor, page.HasMore + l.cursor, l.hasMore, l.limitReached = page.NextCursor, page.HasMore, page.LimitReached a.reproject(p, 0) } }) @@ -383,6 +409,12 @@ func (a *App) setLogReference(p *project, full, short string) { if l.reference == full { return } + if p.walksSeveral() { + // A reference names a commit of one repository, so the log walks that reference in the + // repository whose references it lists rather than every repository together. + a.setLogRepo(p, p.logRepoID(), full, short) + return + } l.reference, l.referenceLabel = full, short a.loadLog(p) } @@ -390,7 +422,11 @@ func (a *App) setLogReference(p *project, full, short string) { // logProjection is what one graph layout is made from, copied so the background work // reads nothing the window thread changes. type logProjection struct { - commits []core.GitCommit + commits []core.GitCommit + // keys and roots are the merged keys and the repository roots of the commits while the log + // walks several repositories, nil while it walks one. + keys, roots []string + origins []logOrigin window []core.GraphCommit remotes []string current string @@ -413,17 +449,24 @@ func (a *App) reproject(p *project, delay time.Duration) { l.projStop = stop in := logProjection{ commits: l.commits, + keys: l.logKeys(), + roots: l.logRoots(), + origins: l.origins, window: l.window, - remotes: remoteNames(l.sections), + remotes: l.logRemoteNames(), current: l.current, expanded: l.expanded, text: strings.ToLower(l.text), user: l.user, path: strings.ToLower(l.path), } - if len(in.window) < len(in.commits) { + if len(in.window) < len(in.commits) || in.origins != nil { in.window = nil } + if in.origins != nil { + // A branch name may be checked out in each of the repositories, so none is the current one. + in.current = "" + } if l.date != logAnyTime { in.after, in.before = logDateBounds(l.date, a.now()) } @@ -468,6 +511,18 @@ func (a *App) reproject(p *project, delay time.Duration) { // run filters the commits and asks the kernel for the layout of what is left. It // returns the files the path filter read, so the next run does not read them again. func (in logProjection) run(ctx context.Context, kernel Kernel, root string, dated bool) (core.Graph, map[string][]core.GitCommitFile, error) { + key := func(i int) string { + if in.keys != nil { + return in.keys[i] + } + return in.commits[i].Hash + } + rootAt := func(i int) string { + if in.roots != nil { + return in.roots[i] + } + return root + } var visible []string if in.text != "" || in.user != "" || in.path != "" || dated { keep := make([]bool, len(in.commits)) @@ -488,13 +543,13 @@ func (in logProjection) run(ctx context.Context, kernel Kernel, root string, dat if !keep[i] { continue } - files, ok := in.pathFiles[c.Hash] + files, ok := in.pathFiles[key(i)] if !ok { var err error - if files, err = kernel.GitCommitFiles(filtering, root, c.Hash); err != nil { + if files, err = kernel.GitCommitFiles(filtering, rootAt(i), c.Hash); err != nil { return core.Graph{}, in.pathFiles, err } - in.pathFiles[c.Hash] = files + in.pathFiles[key(i)] = files } keep[i] = slices.ContainsFunc(files, func(f core.GitCommitFile) bool { return strings.Contains(strings.ToLower(f.Path), in.path) @@ -502,13 +557,13 @@ func (in logProjection) run(ctx context.Context, kernel Kernel, root string, dat } } visible = make([]string, 0, len(in.commits)) - for i, c := range in.commits { + for i := range in.commits { if keep[i] { - visible = append(visible, c.Hash) + visible = append(visible, key(i)) } } } - commits := graphCommits(in.commits) + commits := graphInput(in.commits, in.origins) window := in.window if window == nil { window = commits @@ -525,9 +580,14 @@ func (in logProjection) keepDates(ctx context.Context, kernel Kernel, keep []boo for start := 0; start < len(in.commits); start += logDateChunk { end := min(start+logDateChunk, len(in.commits)) entries := make([]core.HistoryDateEntry, 0, end-start) - for _, c := range in.commits[start:end] { + for i := start; i < end; i++ { + c := in.commits[i] + id := c.Hash + if in.keys != nil { + id = in.keys[i] + } entries = append(entries, core.HistoryDateEntry{ - ID: c.Hash, Date: c.Date, UTCOffsetMinutes: c.DateUTCOffsetMinutes, FallbackUnixSeconds: c.DateUnixSeconds, + ID: id, Date: c.Date, UTCOffsetMinutes: c.DateUTCOffsetMinutes, FallbackUnixSeconds: c.DateUnixSeconds, }) } ids, err := kernel.GitHistoryDates(ctx, entries, in.after, in.before) @@ -539,7 +599,11 @@ func (in logProjection) keepDates(ctx context.Context, kernel Kernel, keep []boo match[id] = true } for i := start; i < end; i++ { - keep[i] = keep[i] && match[in.commits[i].Hash] + id := in.commits[i].Hash + if in.keys != nil { + id = in.keys[i] + } + keep[i] = keep[i] && match[id] } } return nil @@ -600,7 +664,11 @@ func (a *App) selectCommit(p *project, hash string) { stop := make(chan struct{}) l.selStop = stop delay := a.delays.files - kernel, root := a.kernel, p.logRoot() + kernel, root, key := a.kernel, p.logRoot(), hash + if l.origins != nil { + // The commit is read in its own repository, under its hash. + root, hash = p.logCommitAt(key) + } a.background(p, gitTimeout, func(ctx context.Context) func(*App) { if delay > 0 { select { diff --git a/desktop/internal/workbench/gitlog_details_view.go b/desktop/internal/workbench/gitlog_details_view.go index 5556a0bc24..af9ce26412 100644 --- a/desktop/internal/workbench/gitlog_details_view.go +++ b/desktop/internal/workbench/gitlog_details_view.go @@ -261,7 +261,8 @@ func (a *App) compareLogFile(p *project, file string) { if l.selected == "" || i < 0 { return } - a.openCommitDiff(p, p.logRepositoryRoot(), l.selected, l.files[i]) + root, hash := p.logCommitAt(l.selected) + a.openCommitDiff(p, root, hash, l.files[i]) } // showLogFileHistory narrows the log to the commits that changed file. diff --git a/desktop/internal/workbench/gitlog_limits.go b/desktop/internal/workbench/gitlog_limits.go new file mode 100644 index 0000000000..2a1d4afd84 --- /dev/null +++ b/desktop/internal/workbench/gitlog_limits.go @@ -0,0 +1,50 @@ +package workbench + +import "github.com/1lck/Lithe-IDEA/desktop/internal/settingswindow" + +// This file applies the Git Log card of the Version Control settings (matrix id git-history): +// the most commits the log reads of one repository, and of several merged by date. Core reads a +// walk up to its limit and says when the history goes on past it (git.historyPage's +// limitReached), so the log ends there with a note that offers this card instead of failing. + +// gitLogLimit is the most commits the log reads of one repository. +func (a *App) gitLogLimit() int { + return settingswindow.ClampGitLogLimit(a.settings.GitLogLimit, settingswindow.DefaultGitLogLimit) +} + +// gitLogMergedLimit is the most commits the log reads in all while it walks several repositories. +func (a *App) gitLogMergedLimit() int { + return settingswindow.ClampGitLogLimit(a.settings.GitLogMergedLimit, settingswindow.DefaultGitLogMergedLimit) +} + +// setGitLogLimits stores the Git Log's limits, a default as zero, and reads the open log again +// when the limit it walks with changed. +func (a *App) setGitLogLimits(single, merged int) { + stored := func(limit, fallback int) int { + if limit = settingswindow.ClampGitLogLimit(limit, fallback); limit == fallback { + return 0 + } + return limit + } + single = stored(single, settingswindow.DefaultGitLogLimit) + merged = stored(merged, settingswindow.DefaultGitLogMergedLimit) + if a.settings.GitLogLimit == single && a.settings.GitLogMergedLimit == merged { + return + } + singleChanged, mergedChanged := a.settings.GitLogLimit != single, a.settings.GitLogMergedLimit != merged + a.settings.GitLogLimit, a.settings.GitLogMergedLimit = single, merged + a.saveSettings() + p := a.project + if p == nil || !p.log.started { + return + } + if p.walksSeveral() && mergedChanged || !p.walksSeveral() && singleChanged { + a.loadLog(p) + } +} + +// openGitLogLimitSettings opens the Version Control settings, where the Git Log's limits are, +// from the end of a log that reached one. +func (a *App) openGitLogLimitSettings() { + a.openSettingsPage(surfaceButton, settingsVersionControl) +} diff --git a/desktop/internal/workbench/gitlog_limits_test.go b/desktop/internal/workbench/gitlog_limits_test.go new file mode 100644 index 0000000000..b2091ab9c8 --- /dev/null +++ b/desktop/internal/workbench/gitlog_limits_test.go @@ -0,0 +1,84 @@ +package workbench + +import ( + "context" + "slices" + "sync" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/settingswindow" +) + +// cappedHistoryKernel reads the history as gitKernel does but says every walk stopped at its +// limit while the history goes on, and records the most commits each page asked Core to read. +type cappedHistoryKernel struct { + gitKernel + mu sync.Mutex + max []int +} + +func (k *cappedHistoryKernel) GitHistoryPage(ctx context.Context, root, reference, cursor string, limit, maxCommits int) (core.GitHistoryPage, error) { + k.mu.Lock() + k.max = append(k.max, maxCommits) + k.mu.Unlock() + page, err := k.gitKernel.GitHistoryPage(ctx, root, reference, cursor, limit, maxCommits) + page.HasMore, page.NextCursor, page.LimitReached = false, "", true + return page, err +} + +// asked is the most commits each page so far asked Core to read. +func (k *cappedHistoryKernel) asked() []int { + k.mu.Lock() + defer k.mu.Unlock() + return slices.Clone(k.max) +} + +// The log of one repository asks Core to read as many commits as the Git Log settings let it. +// When the history goes on past them, the list ends in a note that older commits are beyond the +// read limit and a button that opens those settings, never a failure and a retry. A changed limit +// is stored, the default as zero, and reads the log again with the new one. +func TestLogEndsAtItsLimitWithANoteThatOpensTheSettings(t *testing.T) { + dir := newTestRepository(t) + gitRun(t, dir, "commit", "-am", "second") + k := &cappedHistoryKernel{gitKernel: gitKernel{core.NewClient()}} + h := newHarness(t, k) + h.app.settings.GitLogLimit = 2000 + p := h.openLog(t, dir) + if got := k.asked(); len(got) == 0 || got[0] != 2000 { + t.Fatalf("the first page asked Core for at most %v commits, want 2000", got) + } + if !p.log.limitReached || p.log.hasMore { + t.Fatalf("the log says limit reached %v, more %v; want the limit note and no more", p.log.limitReached, p.log.hasMore) + } + g := h.app.text.Git + if !h.shows(g.LimitReached(2)) || h.shows(g.LoadMoreFailed) || h.shows(g.Retry) { + t.Fatalf("the end of the log does not say %q alone", g.LimitReached(2)) + } + + log := &treeRecordingLog{} + h.app.logSink = log + t.Cleanup(func() { h.app.logSink = nil }) + h.clickNamed(g.AdjustLimit) + h.settle() + if n := countPerformed(log, "settings.open"); n != 1 { + t.Fatalf("%q opened the settings %d times, want once", g.AdjustLimit, n) + } + + h.app.setGitLogLimits(10000, settingswindow.DefaultGitLogMergedLimit) + h.settleUntil("the log read again", func() bool { + got := k.asked() + return !p.log.loading && got[len(got)-1] == 10000 + }) + if h.app.settings.GitLogLimit != 10000 || h.app.settings.GitLogMergedLimit != 0 { + t.Fatalf("stored limits %d and %d, want 10000 and the default as zero", h.app.settings.GitLogLimit, h.app.settings.GitLogMergedLimit) + } + h.app.setGitLogLimits(settingswindow.DefaultGitLogLimit, 30000) + h.settle() + if h.app.settings.GitLogLimit != 0 || h.app.settings.GitLogMergedLimit != 30000 { + t.Fatalf("stored limits %d and %d, want the default as zero and 30000", h.app.settings.GitLogLimit, h.app.settings.GitLogMergedLimit) + } + if got := k.asked(); got[len(got)-1] != settingswindow.DefaultGitLogLimit { + t.Fatalf("the log of one repository read again with %d, want the default %d", got[len(got)-1], settingswindow.DefaultGitLogLimit) + } +} diff --git a/desktop/internal/workbench/gitlog_multi.go b/desktop/internal/workbench/gitlog_multi.go new file mode 100644 index 0000000000..e20f9056a9 --- /dev/null +++ b/desktop/internal/workbench/gitlog_multi.go @@ -0,0 +1,469 @@ +package workbench + +import ( + "context" + "errors" + "slices" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" +) + +// This file is the Git log that walks several repositories of the project folder at once (matrix +// id git-multi-repository-references), as IntelliJ IDEA's log shows the roots of a project with +// several. The roots list, under the Paths filter and behind the repository name after the filter +// chips, chooses them (gitlog_popover_view.go, git_log_repo.go). Each repository's +// history is read a page at a time; Core interleaves what is loaded by date, each repository in its +// own order (git.workspaceHistoryMerge), and lays the merged list out as one graph whose keys keep +// the repositories apart. Each row is marked in its repository's color, and what a row does, its +// files, details and commit menu, acts on its own repository. + +// historyMerger is the part of the kernel a log of several repositories uses. Core's client +// implements it; a kernel that does not walks one repository at a time. +type historyMerger interface { + SelectWorkspaceRepositories(ctx context.Context, repositories []core.WorkspaceRepository, chosen []string) (core.WorkspaceRepositorySelection, error) + MergeWorkspaceHistories(ctx context.Context, histories []core.WorkspaceHistory) (core.WorkspaceHistoryMerge, error) +} + +// errNoHistoryMerge is the failure of a log of several repositories with a kernel that cannot +// merge their histories. +var errNoHistoryMerge = errors.New("the kernel cannot merge repository histories") + +// historyPager is the part of the kernel that reads a walk's pages. +type historyPager interface { + GitHistoryPage(ctx context.Context, root, reference, cursor string, limit, maxCommits int) (core.GitHistoryPage, error) + CloseGitHistoryCursor(ctx context.Context, root, cursor string) (bool, error) +} + +// readWalkPage reads the next page of w, at most room of the limit commits the log reads in all +// (the Git Log settings' limit for several repositories, which Core's git.workspaceHistoryMerge +// and git.graphProjection take). A first page asks Core to read the walk as far as that limit, +// so no walk stops at Core's own bound first. With no room left, a walk that was not complete +// ends where it is, its cursor closed and marked capped, and the merged list places everything +// it holds and says the log reached its limit. +func readWalkPage(ctx context.Context, pager historyPager, w *logWalk, room, limit int) error { + if room <= 0 { + if w.cursor != "" { + _, _ = pager.CloseGitHistoryCursor(ctx, w.root, w.cursor) + } + w.capped = w.capped || !w.complete + w.cursor, w.complete = "", true + return nil + } + maxCommits := 0 + if w.cursor == "" { + maxCommits = limit + } + page, err := pager.GitHistoryPage(ctx, w.root, "", w.cursor, min(logPageSize, room), maxCommits) + if err != nil { + return err + } + w.commits = slices.Concat(w.commits, page.Commits) + w.cursor, w.complete, w.capped = page.NextCursor, !page.HasMore, page.LimitReached + return nil +} + +// walkCommits is how many commits walks hold in all. +func walkCommits(walks []logWalk) int { + n := 0 + for _, w := range walks { + n += len(w.commits) + } + return n +} + +// logWalk is the history of one repository the log walks with others, as far as it is loaded. +type logWalk struct { + id, root string + commits []core.GitCommit + cursor string + complete bool + // capped says the walk ended at the log's limit while its history goes on. + capped bool + // remotes are the names of the repository's remote branches, which the graph tells from its + // local ones. + remotes []string +} + +// logOrigin is where a row of a log of several repositories comes from: the walk, the key the +// merged graph knows the commit by, and its parents' keys. A key is the hash unless two of the +// repositories name the same hash. +type logOrigin struct { + walk int + key string + parents []string +} + +// walksSeveral reports that the log walks several repositories at once. +func (p *project) walksSeveral() bool { return len(p.nested.chosen) > 1 } + +// logChosen reports that the log walks the repository with ID, alone or among several. +func (p *project) logChosen(id string) bool { + if p.walksSeveral() { + return slices.Contains(p.nested.chosen, id) + } + return id == p.logRepoID() +} + +// logCommitAt is the repository root and the hash of the loaded commit the log knows by key: the +// commit's own repository while the log walks several, the repository it walks otherwise. +func (p *project) logCommitAt(key string) (root, hash string) { + l := &p.log + if l.origins != nil { + if i, ok := l.byHash[key]; ok && i < len(l.origins) { + return l.walks[l.origins[i].walk].root, l.commits[i].Hash + } + } + return p.logRepositoryRoot(), key +} + +// logCommitRepo is the Core ID of the repository of the loaded commit the log knows by key. +func (p *project) logCommitRepo(key string) string { + l := &p.log + if l.origins != nil { + if i, ok := l.byHash[key]; ok && i < len(l.origins) { + return l.walks[l.origins[i].walk].id + } + } + return p.logRepoID() +} + +// referencesAt is the references of the repository at root as the reference pane last read them, +// for a branch dialog that acts in a repository other than the one the log reads its references +// with. +func (p *project) referencesAt(root string) core.GitReferences { + var out core.GitReferences + for _, repo := range p.workspaceRepositories() { + if repo.root == root { + for _, s := range p.nested.references[repo.id].sections { + out.References = append(out.References, s.refs...) + } + break + } + } + return out +} + +// logBranchRepoAt is what the branch dialogs act on for a commit of root: the nested repository's +// root, or empty for the project's own repository. +func (p *project) logBranchRepoAt(root string) string { + if root == p.git.repositoryRoot(p.root) { + return "" + } + return root +} + +// loadLogRepos reads the first page of each repository the log walks, has Core merge them and lay +// the merged list out, and reads the references of the first one for the reference pane. +func (a *App) loadLogRepos(p *project, gen int) { + l := &p.log + merger, ok := a.kernel.(historyMerger) + if !ok { + l.loading, l.err = false, errNoHistoryMerge + return + } + kernel, active, expanded, limit := a.kernel, p.logRoot(), l.expanded, a.gitLogMergedLimit() + walks := make([]logWalk, 0, len(p.nested.chosen)) + for _, id := range p.nested.chosen { + if root := p.rootOf(id); root != "" { + walks = append(walks, logWalk{id: id, root: root}) + } + } + a.background(p, gitTimeout, func(ctx context.Context) func(*App) { + refs, sections, current, err := readReferences(ctx, kernel, active) + for i := range walks { + if err != nil { + break + } + w := &walks[i] + if err = readWalkPage(ctx, kernel, w, limit-walkCommits(walks), limit); err != nil { + break + } + if i == 0 { + w.remotes = remoteNames(sections) + } else if theirs, rerr := kernel.GitReferences(ctx, w.root); rerr == nil { + w.remotes = remoteRefNames(theirs.References) + } + } + var commits []core.GitCommit + var origins []logOrigin + var pending []int + var graph core.Graph + if err == nil { + commits, origins, pending, err = mergeLogWalks(ctx, merger, walks) + } + if err == nil { + input := graphInput(commits, origins) + graph, err = kernel.GitGraph(ctx, core.GraphRequest{ + Commits: input, RemoteNames: walkRemotes(walks), RepositoryCommits: input, Expanded: expanded, + }) + } + return func(a *App) { + if l.gen != gen { + a.closeWalkCursors(p, walks) + return + } + l.loading = false + if err != nil { + a.closeWalkCursors(p, walks) + l.err = err + l.refs, l.sections, l.current = core.GitReferences{}, [3]logSection{}, "" + return + } + l.refs, l.sections, l.current = refs, sections, current + l.walks = walks + l.setMerged(commits, origins, pending) + l.setGraph(graph) + if l.filtered() { + a.reproject(p, 0) + } + } + }) +} + +// loadMoreLogRepos reads the next page of each repository the merged list waits on and merges +// again; the rows placed before stay where they were. +func (a *App) loadMoreLogRepos(p *project) { + l := &p.log + merger, ok := a.kernel.(historyMerger) + if !ok || l.loading || !l.hasMore || l.loadingMore || l.moreFailed || len(l.pending) == 0 { + return + } + l.loadingMore = true + gen, kernel, limit := l.gen, a.kernel, a.gitLogMergedLimit() + walks := slices.Clone(l.walks) + pending := slices.Clone(l.pending) + a.background(p, gitTimeout, func(ctx context.Context) func(*App) { + var err error + for _, i := range pending { + w := &walks[i] + if w.complete || w.cursor == "" { + continue + } + if err = readWalkPage(ctx, kernel, w, limit-walkCommits(walks), limit); err != nil { + break + } + } + var commits []core.GitCommit + var origins []logOrigin + if err == nil { + commits, origins, pending, err = mergeLogWalks(ctx, merger, walks) + } + return func(a *App) { + if l.gen != gen { + a.closeWalkCursors(p, walks) + return + } + l.loadingMore = false + if err != nil { + l.moreFailed = true + return + } + l.walks = walks + l.setMerged(commits, origins, pending) + a.reproject(p, 0) + } + }) +} + +// setMerged keeps the merged list of the walks and what it waits on, and whether a walk ended at +// the log's limit. +func (l *gitLogState) setMerged(commits []core.GitCommit, origins []logOrigin, pending []int) { + l.commits, l.origins, l.pending = commits, origins, pending + l.byHash = make(map[string]int, len(origins)) + for i := range origins { + l.byHash[origins[i].key] = i + } + l.cursor, l.hasMore = "", len(pending) > 0 + l.limitReached = slices.ContainsFunc(l.walks, func(w logWalk) bool { return w.capped }) +} + +// mergeLogWalks has Core merge the loaded commits of walks and returns the merged list, where +// each of its rows comes from, and the walks whose next page the list waits on. +func mergeLogWalks(ctx context.Context, merger historyMerger, walks []logWalk) ([]core.GitCommit, []logOrigin, []int, error) { + histories := make([]core.WorkspaceHistory, len(walks)) + for i, w := range walks { + commits := make([]core.WorkspaceHistoryCommit, len(w.commits)) + for j, c := range w.commits { + commits[j] = core.WorkspaceHistoryCommit{Hash: c.Hash, ParentHashes: c.ParentHashes, Timestamp: c.DateUnixSeconds} + } + histories[i] = core.WorkspaceHistory{ID: w.id, Commits: commits, Complete: w.complete} + } + merged, err := merger.MergeWorkspaceHistories(ctx, histories) + if err != nil { + return nil, nil, nil, err + } + commits := make([]core.GitCommit, 0, len(merged.Entries)) + origins := make([]logOrigin, 0, len(merged.Entries)) + for _, e := range merged.Entries { + if e.Repository < 0 || e.Repository >= len(walks) || e.Index < 0 || e.Index >= len(walks[e.Repository].commits) { + continue + } + commits = append(commits, walks[e.Repository].commits[e.Index]) + origins = append(origins, logOrigin{walk: e.Repository, key: e.Key, parents: e.ParentKeys}) + } + return commits, origins, merged.Pending, nil +} + +// graphInput is what the graph is laid out from: the commits, under their merged keys when +// origins are given. +func graphInput(commits []core.GitCommit, origins []logOrigin) []core.GraphCommit { + out := graphCommits(commits) + if origins == nil { + return out + } + for i := range out { + out[i].Hash, out[i].ParentHashes = origins[i].key, origins[i].parents + } + return out +} + +// logKeys are the keys of the merged list's rows, nil while the log walks one repository. +func (l *gitLogState) logKeys() []string { + if l.origins == nil { + return nil + } + keys := make([]string, len(l.origins)) + for i := range l.origins { + keys[i] = l.origins[i].key + } + return keys +} + +// logRoots are the repository roots of the merged list's rows, nil while the log walks one +// repository. +func (l *gitLogState) logRoots() []string { + if l.origins == nil { + return nil + } + roots := make([]string, len(l.origins)) + for i := range l.origins { + roots[i] = l.walks[l.origins[i].walk].root + } + return roots +} + +// logRemoteNames are the remote branch names the graph tells from local ones: those of every +// repository the log walks. +func (l *gitLogState) logRemoteNames() []string { + if l.walks != nil { + return walkRemotes(l.walks) + } + return remoteNames(l.sections) +} + +// walkRemotes are the remote branch names of walks, each once. +func walkRemotes(walks []logWalk) []string { + var names []string + for _, w := range walks { + for _, name := range w.remotes { + if !slices.Contains(names, name) { + names = append(names, name) + } + } + } + return names +} + +// remoteRefNames are the short names of the remote branches among refs. +func remoteRefNames(refs []core.GitReference) []string { + var names []string + for _, r := range refs { + if r.Kind == "remote" { + names = append(names, r.ShortName) + } + } + return names +} + +// closeWalkCursors releases the history walks of walks the log no longer continues. +func (a *App) closeWalkCursors(p *project, walks []logWalk) { + kernel := a.kernel + type open struct{ root, cursor string } + var cursors []open + for _, w := range walks { + if w.cursor != "" { + cursors = append(cursors, open{w.root, w.cursor}) + } + } + if len(cursors) == 0 { + return + } + a.background(p, gitTimeout, func(ctx context.Context) func(*App) { + for _, c := range cursors { + _, _ = kernel.CloseGitHistoryCursor(ctx, c.root, c.cursor) + } + return nil + }) +} + +// chooseLogRepos makes the log walk the repositories with ids, in the order Core lists them, and +// reads it again. One repository walks it alone, as setLogRepo does. +func (a *App) chooseLogRepos(p *project, ids []string) { + if len(ids) == 1 { + a.setLogRepo(p, ids[0], "", "") + return + } + if len(ids) == 0 { + return + } + selection, ok := a.workspaceRepositories(p, ids) + if !ok { + return + } + a.applyLogRepos(p, selection) + a.loadLog(p) +} + +// toggleLogRoot adds the repository with ID to the ones the log walks, or takes it out, and +// reads the log again. The last repository stays. +func (a *App) toggleLogRoot(p *project, id string) { + chosen := p.nested.chosen + if !p.walksSeveral() { + chosen = []string{p.logRepoID()} + } + if i := slices.Index(chosen, id); i >= 0 { + if len(chosen) == 1 { + return + } + chosen = slices.Delete(slices.Clone(chosen), i, i+1) + } else { + chosen = append(slices.Clone(chosen), id) + } + a.chooseLogRepos(p, chosen) +} + +// workspaceRepositories asks Core which of the repositories with ids the log walks, in its order. +// It reports false, after logging why, when Core cannot answer. +func (a *App) workspaceRepositories(p *project, ids []string) (core.WorkspaceRepositorySelection, bool) { + merger, ok := a.kernel.(historyMerger) + if !ok { + return core.WorkspaceRepositorySelection{}, false + } + ctx, cancel := context.WithTimeout(context.Background(), kernelCallTimeout) + defer cancel() + selection, err := merger.SelectWorkspaceRepositories(ctx, p.nested.discovered, ids) + if err != nil { + a.backgroundFailed("workspace_repository_selection", err) + return core.WorkspaceRepositorySelection{}, false + } + return selection, true +} + +// applyLogRepos makes Core's selection of several repositories the ones the log walks. It closes +// the history walks of the repositories it walked before and drops the reference it walked, which +// belonged to one repository. +func (a *App) applyLogRepos(p *project, selection core.WorkspaceRepositorySelection) { + a.releaseLogCursor(p) + n := &p.nested + n.others = selection.Others + n.chosen = nil + if len(selection.Chosen) > 1 { + n.chosen = selection.Chosen + } + active := selection.Active + if _, nested := n.repo(active); !nested { + active = "" + } + n.logRepo = active + p.log.reference, p.log.referenceLabel, p.log.refSelected = "", "", "" +} diff --git a/desktop/internal/workbench/gitlog_multi_test.go b/desktop/internal/workbench/gitlog_multi_test.go new file mode 100644 index 0000000000..c9d6dde0c2 --- /dev/null +++ b/desktop/internal/workbench/gitlog_multi_test.go @@ -0,0 +1,198 @@ +package workbench + +import ( + "context" + "path/filepath" + "slices" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" +) + +// A folder holding repositories lists a node per repository in the Git Log's reference pane, each +// with its own sections, and a click on another repository's branch walks that branch there. The +// name after the filter chips lists the repositories: a second checked box merges both histories +// into one list by date, each commit in its repository's color, its details and its commit menu in +// its repository; unchecking a box walks the other repository alone again. +func TestWorkspaceLogWalksSeveralRepositoriesTogether(t *testing.T) { + parent := newWorkspaceFolder(t, "alpha", "beta") + h := newHarness(t, &gitKernel{Client: core.NewClient()}) + p := h.openWorkspaceFolder(parent) + alphaID, betaID := repositoryID(t, p, "alpha"), repositoryID(t, p, "beta") + h.app.layout.gitTab = gitTabLog + if !h.app.chrome.isOpen(catalogIndex[itemGit]) { + h.click(center(h.button(itemGit))) + } + h.settleUntil("alpha's history and beta's references", func() bool { + _, read := p.nested.references[betaID] + return p.logRepoID() == alphaID && !p.log.loading && len(p.log.graph.Rows) == 1 && read + }) + h.settle() + + v := &h.app.logView + for _, id := range []string{alphaID, betaID} { + node := slices.IndexFunc(v.refItems, func(r logRefRow) bool { return r.kind == logRefRepository && r.repo == id }) + if node < 0 || node+1 >= len(v.refItems) || v.refItems[node+1].kind != logRefSection || v.refItems[node+1].depth != 1 { + t.Fatalf("repository %q has no node with its own sections in %+v", id, v.refItems) + } + } + foreign := slices.IndexFunc(v.refItems, func(r logRefRow) bool { + return r.kind == logRefForeign && r.repo == betaID && r.short == "main" + }) + if foreign < 0 { + t.Fatalf("beta's node lists no main branch in %+v", v.refItems) + } + h.click(center(h.topHit(v.refs.RowID(foreign)))) + h.settleUntil("beta's main", func() bool { + return p.logRepoID() == betaID && p.log.reference == "refs/heads/main" && !p.log.loading && len(p.log.graph.Rows) == 1 + }) + + lang, g := h.app.language(), h.app.text.Git.Repositories + h.click(center(h.hitLabeled(g.Choose))) + if p.log.popover != logPopoverRoots { + t.Fatalf("popover %v after clicking the repository name, want the repository list", p.log.popover) + } + toggle := func(name string) { + t.Helper() + label := i18n.SharedFormat(lang, "desktop.nested.rootToggle", map[string]string{"name": name}) + h.click(center(h.hitLabeled(label))) + } + toggle("alpha") + h.settleUntil("both histories in one list", func() bool { + return p.walksSeveral() && !p.log.loading && len(p.log.graph.Rows) == 2 + }) + if p.log.reference != "" { + t.Fatalf("the merged list walks reference %q, want every repository's HEAD", p.log.reference) + } + for _, subject := range []string{"initial alpha", "initial beta"} { + if !h.shows(subject) { + t.Fatalf("the merged list does not show %q", subject) + } + } + if !h.shows(g.Several(2)) { + t.Fatalf("the name after the chips is not %q", g.Several(2)) + } + betaRow := -1 + repos := map[string]bool{} + for i, row := range p.log.graph.Rows { + id := p.logCommitRepo(row.CommitHash) + repos[id] = true + if id == betaID { + betaRow = i + } + } + if !repos[alphaID] || !repos[betaID] || betaRow < 0 { + t.Fatalf("the merged rows belong to %v, want alpha and beta", repos) + } + + root, _, hashes := h.app.logMenuTarget(p, betaRow) + if filepath.Base(root) != "beta" || len(hashes) != 1 { + t.Fatalf("beta's commit menu acts on %v in %q, want its commit in beta", hashes, root) + } + if want := gitRun(t, filepath.Join(parent, "beta"), "rev-parse", "HEAD"); hashes[0] != want { + t.Fatalf("beta's commit menu acts on %q, want beta's HEAD %q", hashes[0], want) + } + h.app.selectCommit(p, p.log.graph.Rows[betaRow].CommitHash) + h.settleUntil("beta's commit files", func() bool { return p.log.filesState == logFilesReady }) + if len(p.log.files) != 1 || p.log.files[0].Path != "beta.txt" { + t.Fatalf("beta's commit lists %+v, want beta.txt read from beta", p.log.files) + } + + toggle("alpha") + h.settleUntil("beta alone again", func() bool { + return !p.walksSeveral() && p.logRepoID() == betaID && !p.log.loading && len(p.log.graph.Rows) == 1 + }) + if !h.shows("initial beta") || h.shows("initial alpha") { + t.Fatal("after unchecking alpha the log does not show beta's history alone") + } +} + +// endlessPager reads pages of a history that never ends and records the limits and the most +// commits it is asked for and the cursors it closes. With bound set, a walk ends there: the page +// that reaches it says LimitReached. +type endlessPager struct { + limits []int + maxCommits []int + closed []string + bound bool +} + +func (f *endlessPager) GitHistoryPage(_ context.Context, _, _, _ string, limit, maxCommits int) (core.GitHistoryPage, error) { + f.limits, f.maxCommits = append(f.limits, limit), append(f.maxCommits, maxCommits) + if f.bound { + return core.GitHistoryPage{Commits: make([]core.GitCommit, limit), LimitReached: true}, nil + } + return core.GitHistoryPage{Commits: make([]core.GitCommit, limit), NextCursor: "next", HasMore: true}, nil +} + +func (f *endlessPager) CloseGitHistoryCursor(_ context.Context, _, cursor string) (bool, error) { + f.closed = append(f.closed, cursor) + return true, nil +} + +// A log of several repositories reads no more commits than its limit: the last page takes the +// room that is left, and a walk with none left ends where it is, its cursor closed and marked +// capped, so the merged list ends with a note instead of failing the next merge. +func TestMergedLogReadsNoMoreThanItsLimit(t *testing.T) { + const limit = 20000 + ctx, pager := context.Background(), &endlessPager{} + walks := []logWalk{ + {id: "a", root: "/a", commits: make([]core.GitCommit, limit-30), cursor: "a1"}, + {id: "b", root: "/b", cursor: "b1"}, + {id: "c", root: "/c"}, + } + read := func(i int) { + t.Helper() + if err := readWalkPage(ctx, pager, &walks[i], limit-walkCommits(walks), limit); err != nil { + t.Fatalf("walk %q: %v", walks[i].id, err) + } + } + read(1) + if len(walks[1].commits) != 30 || walks[1].complete || walks[1].cursor != "next" { + t.Fatalf("the last page is %d commits, complete %v, cursor %q; want the 30 left and more to come", + len(walks[1].commits), walks[1].complete, walks[1].cursor) + } + read(0) + read(1) + read(2) + if !slices.Equal(pager.limits, []int{30}) || !slices.Equal(pager.maxCommits, []int{0}) { + t.Fatalf("pages asked for %v up to %v, want one of the 30 left that goes on with its walk", pager.limits, pager.maxCommits) + } + if !slices.Equal(pager.closed, []string{"a1", "next"}) { + t.Fatalf("closed cursors %v, want a's and b's and none for c, which read no page", pager.closed) + } + for _, w := range walks { + if !w.complete || w.cursor != "" || !w.capped { + t.Fatalf("walk %q is complete %v, capped %v, with cursor %q after the room ran out", w.id, w.complete, w.capped, w.cursor) + } + } + if n := walkCommits(walks); n != limit { + t.Fatalf("the walks hold %d commits, want %d", n, limit) + } + var l gitLogState + l.walks = walks + l.setMerged(nil, nil, nil) + if !l.limitReached || l.hasMore { + t.Fatalf("the merged log says limit reached %v, more %v; want the limit note and no more", l.limitReached, l.hasMore) + } +} + +// A walk's first page asks Core to read it as far as the log's limit, and a walk Core ends there +// is capped, while one that read its whole history is not. +func TestMergedLogWalkEndsAtCoresBound(t *testing.T) { + ctx, pager := context.Background(), &endlessPager{bound: true} + w := logWalk{id: "a", root: "/a"} + if err := readWalkPage(ctx, pager, &w, 500, 500); err != nil { + t.Fatal(err) + } + if !slices.Equal(pager.maxCommits, []int{500}) || !w.complete || !w.capped { + t.Fatalf("first page asked up to %v; walk complete %v, capped %v; want 500, complete and capped", pager.maxCommits, w.complete, w.capped) + } + var l gitLogState + l.walks = []logWalk{{id: "b", complete: true}} + l.setMerged(nil, nil, nil) + if l.limitReached { + t.Fatal("a log whose walks read their whole histories says it reached its limit") + } +} diff --git a/desktop/internal/workbench/gitlog_page.go b/desktop/internal/workbench/gitlog_page.go index 317037a311..86039f2bae 100644 --- a/desktop/internal/workbench/gitlog_page.go +++ b/desktop/internal/workbench/gitlog_page.go @@ -183,7 +183,7 @@ func newLogView() logView { v := logView{detailWidth: logDetailsWidth} v.refSplit.Pos = logRefsWidth v.filesSplit.Pos = logFilesHeight - v.refs.RowHeight, v.refs.Indent = logItemHeight, logIndent + v.refs.RowHeight = logItemHeight return v } @@ -279,10 +279,10 @@ type logRefRow struct { // (nil for HEAD, which stands for every reference). short string ref *core.GitReference - // repo is the ID of the repository a group or one of its references belongs to. + // repo is the ID of the repository a node or a foreign reference belongs to. repo string open bool - // tint is the color of a repository group (nested_refs.go). + // tint is the color of a repository node (nested_refs.go). tint gfx.Color } @@ -294,8 +294,9 @@ const ( logRefSection logRefFolder logRefReference - // logRefRepository is the group of a repository other than the one the log walks; logRefForeign - // is one of its references, which a click makes the log walk. + // logRefRepository is the node of a repository in a folder with several; logRefForeign is a + // reference of a repository other than the one the log reads its references with, which a click + // walks in its repository. logRefRepository logRefForeign ) diff --git a/desktop/internal/workbench/gitlog_popover_view.go b/desktop/internal/workbench/gitlog_popover_view.go index 91414d98be..e3cc096d85 100644 --- a/desktop/internal/workbench/gitlog_popover_view.go +++ b/desktop/internal/workbench/gitlog_popover_view.go @@ -38,7 +38,7 @@ func (a *App) drawLogPopover(c ui.C, p *project, which logPopover, anchor ui.Box return } width := float32(logPopoverWidth) - if which == logPopoverPath { + if which == logPopoverPath || which == logPopoverRoots { width = logPathWidth } open := true @@ -53,6 +53,8 @@ func (a *App) drawLogPopover(c ui.C, p *project, which logPopover, anchor ui.Box a.drawLogDateFilter(c, p) case logPopoverPath: a.drawLogPathFilter(c, p) + case logPopoverRoots: + a.drawLogRoots(c, p) } }) if !open { @@ -249,39 +251,58 @@ func (a *App) drawLogPathFilter(c ui.C, p *project) { }) }) if p.workspaceMode() { + ui.Divider(c) a.drawLogRoots(c, p) } } -// drawLogRoots declares the repositories of the project folder under the Paths filter, as IDEA's -// filter lists the roots of a project with several: each in its color, the one the log walks -// checked. A click walks that repository's history. +// drawLogRoots declares the repositories of the project folder, as IDEA's root filter lists the +// roots of a project with several: each in its color, with its box checked while the log walks it. +// A box adds its repository to the ones the log walks, or takes it out, and the log lists the +// commits of every checked repository in one list by date; a click on a name walks that repository +// alone. Select All checks every box. func (a *App) drawLogRoots(c ui.C, p *project) { l := &p.log - walked := p.logRepoID() - ui.Divider(c) + lang := a.language() + repos := p.workspaceRepositories() + all := true + for _, repo := range repos { + all = all && p.logChosen(repo.id) + } ui.Column(c).FillWidth().Gap(2).Children(func() { - ui.Text(c, i18n.Shared(a.language(), "desktop.nested.roots")).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle) - for _, repo := range p.workspaceRepositories() { - checked := repo.id == walked - item := ui.Row(c.Key("root/"+repo.id)).Height(logItemHeight+2).FillWidth().Shrink(0).Items(ui.Center).Gap(8).PadX(8). + ui.Row(c).FillWidth().Items(ui.Center).Gap(8).PadX(8).Children(func() { + ui.Text(c, i18n.Shared(lang, "desktop.nested.roots")).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle).Grow(1) + if ui.Button(c.Part("roots-all"), i18n.Shared(lang, "desktop.nested.rootsAll")).Ghost().Disabled(all).Clicked() { + ids := make([]string, len(repos)) + for i, repo := range repos { + ids[i] = repo.id + } + c.After(func() { a.chooseLogRepos(p, ids) }) + } + }) + for _, repo := range repos { + rc := c.Key("root/" + repo.id) + checked := p.logChosen(repo.id) + item := ui.Row(rc).Height(logItemHeight+2).FillWidth().Shrink(0).Items(ui.Center).Gap(8).PadX(8). Radius(a.theme.Metrics.RadiusItem()). - HitWith(ui.ID(c), repo.name, gfx.HitOptions{Role: gfx.RoleMenuItem, Selected: checked}). + HitWith(ui.ID(rc), repo.name, gfx.HitOptions{Role: gfx.RoleMenuItem, Selected: checked}). Hover(ui.Look{}.Background(a.colors.Hover)).Pressed(ui.Look{}.Background(a.colors.Active)) + toggled := false item.Children(func() { - if checked { - ui.Icon(c, icons.Check).Size(14, 14).Color(a.colors.Accent) - } else { - ui.Row(c).Size(14, 14).Shrink(0) - } - a.drawRepositorySwatch(c, p, repo.id) - ui.Text(c, repo.name).Color(a.colors.Text).Ellipsis().Grow(1) + on := checked + label := i18n.SharedFormat(lang, "desktop.nested.rootToggle", map[string]string{"name": repo.name}) + toggled = ui.Checkbox(rc, &on, "").Label(label).Clicked() + a.drawRepositorySwatch(rc, p, repo.id) + ui.Text(rc, repo.name).Color(a.colors.Text).Ellipsis().Grow(1) }) - if item.Clicked() { - id := repo.id + id := repo.id + switch { + case toggled: + c.After(func() { a.toggleLogRoot(p, id) }) + case item.Clicked(): c.After(func() { l.popover = logPopoverNone - a.setLogRepo(p, id, "", "") + a.chooseLogRepos(p, []string{id}) }) } } diff --git a/desktop/internal/workbench/gitlog_view.go b/desktop/internal/workbench/gitlog_view.go index e618a53d37..c31d1e55d9 100644 --- a/desktop/internal/workbench/gitlog_view.go +++ b/desktop/internal/workbench/gitlog_view.go @@ -152,15 +152,26 @@ func (a *App) drawLogStripe(c ui.C, p *project) { c.After(func() { clear(l.collapsed) }) } if a.gitIconButton(c, g.CollapseAll, icons.ChevronsDownUp, false, false) { - c.After(func() { - for _, s := range l.sections { - l.collapsed["s"+s.kind] = true - } - }) + c.After(func() { a.collapseLogRefs(p) }) } }) } +// collapseLogRefs closes every section of the reference pane, and every repository's node in a +// folder with several. +func (a *App) collapseLogRefs(p *project) { + l := &p.log + if p.workspaceMode() { + for _, repo := range p.workspaceRepositories() { + l.collapsed[logRepoRefKey(repo.id)] = true + } + return + } + for _, s := range l.sections { + l.collapsed["s"+s.kind] = true + } +} + // drawLogHiddenStripe is the stripe that stands for the reference pane while it is hidden. func (a *App) drawLogHiddenStripe(c ui.C, p *project) { ui.Column(c).Width(logStripeWidth).Shrink(0).FillHeight().Items(ui.Center).PadY(6).Gap(4).Background(a.colors.Panel).Children(func() { @@ -183,6 +194,9 @@ func (a *App) drawLogReferences(c ui.C, p *project) ui.Box { ui.TextFieldID(c, logRefSearchID, &v.refSearch, g.BranchSearch, g.BranchSearch).Grow(1) }) ui.Divider(c) + // A level starts an icon and a gap right of its parent, so a row's arrow or icon is under + // its parent's name, as in IDEA's branch tree. + v.refs.Indent = logRefRowIcon + c.Theme().Metrics.GapItem ui.Tree(c, &v.refs, len(v.refItems), v.refLabel, func(i int) { a.drawLogRefContent(c, p, v.refs.RowID(i), v.refItems[i]) }).Scrollbars().Grow(1).PadY(4) @@ -200,20 +214,40 @@ func (a *App) drawLogReferences(c ui.C, p *project) ui.Box { // buildLogRefRows lists the rows the reference pane shows for query: HEAD, then each section // with the folders and references of its tree, or only the matching references while the -// filter has text. It returns how many references the sections list. +// filter has text. A folder with several repositories lists a node per repository instead, each +// with its own sections (appendRepositoryLogRows). It returns how many references the pane lists. func (a *App) buildLogRefRows(p *project, query string) (shown int) { l, v := &p.log, &a.logView rows := v.refItems[:0] - labels := [3]string{a.text.Git.LocalGroup, a.text.Git.RemoteGroup, a.text.Git.TagGroup} if query == "" { rows = append(rows, logRefRow{kind: logRefHead, label: a.text.Git.HeadRow, key: "HEAD", short: "HEAD"}) } - for i := range l.sections { - s := &l.sections[i] + if p.workspaceMode() { + rows, shown = a.appendRepositoryLogRows(rows, p, query) + } else { + rows, shown = a.appendLogSections(rows, p, "", "", &l.sections, 0, query) + } + v.refItems = rows + return shown +} + +// appendLogSections appends the sections of one repository's references at depth, keyed under +// prefix. foreign is the Core ID of a repository other than the one whose references the log reads +// with its history, whose references then walk it on a click; empty for that one. It returns how +// many references the sections list. +func (a *App) appendLogSections(rows []logRefRow, p *project, prefix, foreign string, sections *[3]logSection, depth int, query string) ([]logRefRow, int) { + labels := [3]string{a.text.Git.LocalGroup, a.text.Git.RemoteGroup, a.text.Git.TagGroup} + kind := logRefReference + if foreign != "" { + kind = logRefForeign + } + shown := 0 + for i := range sections { + s := §ions[i] if len(s.refs) == 0 { continue } - section := logRefRow{kind: logRefSection, label: labels[i], key: "s" + s.kind, open: true} + section := logRefRow{kind: logRefSection, depth: depth, label: labels[i], key: prefix + "s" + s.kind, repo: foreign, open: true} if query != "" { matches := slices.DeleteFunc(slices.Clone(s.refs), func(r core.GitReference) bool { return !strings.Contains(strings.ToLower(r.ShortName), query) @@ -224,41 +258,41 @@ func (a *App) buildLogRefRows(p *project, query string) (shown int) { shown += len(matches) rows = append(rows, section) for j := range matches { - rows = append(rows, logRefRow{kind: logRefReference, depth: 1, label: matches[j].ShortName, key: matches[j].FullName, short: matches[j].ShortName, ref: &matches[j]}) + rows = append(rows, logRefRow{kind: kind, depth: depth + 1, label: matches[j].ShortName, key: matches[j].FullName, short: matches[j].ShortName, ref: &matches[j], repo: foreign}) } continue } shown += len(s.refs) - section.open = !l.collapsed[section.key] + section.open = !p.log.collapsed[section.key] rows = append(rows, section) if section.open { - rows = a.appendLogNodes(rows, p, s, s.nodes, 1) + rows = a.appendLogNodes(rows, p, prefix, foreign, s, s.nodes, depth+1) } } - var nested int - rows, nested = a.appendNestedLogRows(rows, p, query) - shown += nested - v.refItems = rows - return shown + return rows, shown } // appendLogNodes appends the folders and references of a section's tree, the folders that are // open with what is in them. -func (a *App) appendLogNodes(rows []logRefRow, p *project, s *logSection, nodes []core.ReferenceTreeNode, depth int) []logRefRow { +func (a *App) appendLogNodes(rows []logRefRow, p *project, prefix, foreign string, s *logSection, nodes []core.ReferenceTreeNode, depth int) []logRefRow { + kind := logRefReference + if foreign != "" { + kind = logRefForeign + } for i := range nodes { node := &nodes[i] if node.Reference != nil { if r := *node.Reference; r >= 0 && r < len(s.refs) { ref := &s.refs[r] - rows = append(rows, logRefRow{kind: logRefReference, depth: depth, label: node.Name, key: ref.FullName, short: ref.ShortName, ref: ref}) + rows = append(rows, logRefRow{kind: kind, depth: depth, label: node.Name, key: ref.FullName, short: ref.ShortName, ref: ref, repo: foreign}) } continue } - key := "f" + s.kind + "/" + node.Path + key := prefix + "f" + s.kind + "/" + node.Path open := !p.log.collapsed[key] rows = append(rows, logRefRow{kind: logRefFolder, depth: depth, label: node.Name, key: key, open: open}) if open { - rows = a.appendLogNodes(rows, p, s, node.Children, depth+1) + rows = a.appendLogNodes(rows, p, prefix, foreign, s, node.Children, depth+1) } } return rows @@ -280,20 +314,44 @@ func (v *logView) refNode(i int) ui.TreeNode { // refRowLabel is the accessible name of row i of the reference pane. func (v *logView) refRowLabel(i int) string { return v.refItems[i].label } -// drawLogRefContent declares what row of the reference pane shows after its arrow. The name of -// a reference of the repository the log walks labels the row and carries the reference's menu. +// logRefRowIcon is the size of the icon of a row of the reference pane. +const logRefRowIcon = 14 + +// drawLogRefContent declares what row of the reference pane shows after its arrow. Viva's Tree +// starts a row without an arrow (HEAD, a reference) where the arrow of a row with one is, so such +// a row keeps the arrow's room empty, and its icon lines up with the name of a section or the +// icon of a folder beside it. func (a *App) drawLogRefContent(c ui.C, p *project, row gfx.ID, r logRefRow) { + switch r.kind { + case logRefHead, logRefReference, logRefForeign: + ui.Row(c).Grow(1).Shrink(1).Items(ui.Center).Gap(c.Theme().Metrics.GapItem).PadLeft(treeChevron).Children(func() { + a.drawLogRefLeaf(c, p, row, r) + }) + return + } switch r.kind { case logRefSection: ui.Text(c, r.label).Weight(gfx.WeightMedium).Ellipsis().Grow(1) case logRefRepository: - ui.Icon(c, icons.Folder).Size(14, 14).Color(r.tint) + ui.Icon(c, icons.Folder).Size(logRefRowIcon, logRefRowIcon).Color(r.tint) ui.Text(c, r.label).Weight(gfx.WeightMedium).Color(r.tint).Ellipsis().Grow(1) + if p.logChosen(r.repo) { + // The repositories the log walks are checked, as the roots list checks them. + ui.Icon(c, icons.Check).Size(12, 12).Shrink(0).Color(a.colors.Subtle) + } case logRefFolder: - ui.Icon(c, icons.Folder).Size(14, 14).Color(a.colors.Subtle) + ui.Icon(c, icons.Folder).Size(logRefRowIcon, logRefRowIcon).Color(a.colors.Subtle) ui.Text(c, r.label).Ellipsis().Grow(1) + } +} + +// drawLogRefLeaf declares the icon, name and distance from its upstream of HEAD or a reference +// in the reference pane. The name of a reference of the repository the log walks labels the row +// and carries the reference's menu. +func (a *App) drawLogRefLeaf(c ui.C, p *project, row gfx.ID, r logRefRow) { + switch r.kind { case logRefHead: - ui.Icon(c, icons.Tag).Size(14, 14).Color(referenceColor("head", a.colors.Dark)) + ui.Icon(c, icons.Tag).Size(logRefRowIcon, logRefRowIcon).Color(referenceColor("head", a.colors.Dark)) ui.Text(c, r.label).Ellipsis().Grow(1) case logRefReference, logRefForeign: ref := r.ref @@ -312,7 +370,7 @@ func (a *App) drawLogRefContent(c ui.C, p *project, row gfx.ID, r logRefRow) { if ref.Behind > 0 { trailing = strings.TrimSpace(trailing + " ↓" + strconv.Itoa(ref.Behind)) } - ui.Icon(c, icon).Size(14, 14).Color(referenceColor(kind, a.colors.Dark)) + ui.Icon(c, icon).Size(logRefRowIcon, logRefRowIcon).Color(referenceColor(kind, a.colors.Dark)) name := ui.Text(c, r.label).Ellipsis().Grow(1) if r.kind == logRefReference { a.drawLogRefMenu(c, name.LabelFor(row), p, *ref) @@ -331,16 +389,14 @@ func (a *App) toggleLogRef(p *project, r logRefRow, query string) { } } -// chooseLogRef acts on a click on a row of the reference pane: a section or folder folds, a -// repository's group or one of its references makes that repository the one the log walks, and a +// chooseLogRef acts on a click on a row of the reference pane: a repository's node, a section or a +// folder folds, a reference of another repository walks that reference in its repository, and a // reference of the walked repository becomes the one the log walks. func (a *App) chooseLogRef(p *project, r logRefRow, query string) { l := &p.log switch r.kind { - case logRefSection, logRefFolder: + case logRefSection, logRefFolder, logRefRepository: a.toggleLogRef(p, r, query) - case logRefRepository: - a.setLogRepo(p, r.repo, "", "") case logRefForeign: a.setLogRepo(p, r.repo, r.ref.FullName, r.ref.ShortName) default: @@ -584,28 +640,61 @@ func (a *App) drawLogViewMore(c ui.C, p *project, first int) { } } -// drawLogRepoLabel declares, in the filter bar after the Paths chip, the repository the log walks, -// and, while a nested repository is walked in a folder that is a repository itself, the way back to -// the project's own. It shows only in a workspace with nested repositories; the Paths filter lists -// the roots to walk another one (drawLogRoots). The bar is short of room, so the label shows the -// repository's folder in its color and its name, keeps that width, and says it is the repository -// the log walks in its tip. +// drawLogRepoLabel declares, after the filter chips, the name of the repository the log walks in +// its color, or the colors and the count of the repositories it walks together. A click lists the +// repositories of the folder to walk (drawLogRoots). While the log walks a nested repository alone +// a button leads back to the project's own. func (a *App) drawLogRepoLabel(c ui.C, p *project) { + l := &p.log if !p.workspaceMode() && p.nested.logRepo == "" { return } g := a.text.Git.Repositories id := p.logRepoID() - name := p.repositoryName(id) - tint := a.repositoryTint(p, id) + name, tint := p.repositoryName(id), a.repositoryTint(p, id) + several := p.walksSeveral() + if several { + name, tint = g.Several(len(p.nested.chosen)), a.colors.Text + } + tip := g.Current(name) + if p.workspaceMode() { + tip = g.Choose + } rc := c.Part("repo") - ui.Row(rc).Shrink(0).Items(ui.Center).Gap(4).PadX(4). - HitWith(ui.ID(rc), g.Current(name), gfx.HitOptions{Role: gfx.RoleStatus}).Tooltip(g.Current(name)). - Children(func() { + open := l.popover == logPopoverRoots + label := ui.Row(rc).Height(logButtonSize).Shrink(0).Items(ui.Center).Gap(4).PadX(6). + Radius(a.theme.Metrics.RadiusItem()) + if p.workspaceMode() { + label = label.HitWith(ui.ID(rc), tip, gfx.HitOptions{Role: gfx.RoleButton, Cursor: gfx.PointerCursorHand}) + if open { + label = label.Background(a.colors.Active) + } else { + label = label.Hover(ui.Look{}.Background(a.colors.Hover)) + } + } else { + label = label.HitWith(ui.ID(rc), tip, gfx.HitOptions{Role: gfx.RoleStatus}) + } + label = label.Tooltip(tip) + label.Children(func() { + if several { + for _, chosen := range p.nested.chosen { + a.drawRepositorySwatch(rc, p, chosen) + } + } else { ui.Icon(rc, icons.Folder).Size(14, 14).Shrink(0).Color(tint) - ui.Text(rc, name).Weight(gfx.WeightMedium).Color(tint).Ellipsis().MaxWidth(160) - }) - if p.nested.logRepo != "" && p.git.isRepository() { + } + ui.Text(rc, name).Weight(gfx.WeightMedium).Color(tint).Ellipsis().MaxWidth(160) + if p.workspaceMode() { + ui.Icon(rc, icons.ChevronDown).Size(12, 12).Shrink(0).Color(a.colors.Subtle) + } + }) + if p.workspaceMode() { + if label.Clicked() { + c.After(func() { a.toggleLogPopover(p, logPopoverRoots) }) + } + a.drawLogPopover(c, p, logPopoverRoots, label) + } + if !several && p.nested.logRepo != "" && p.git.isRepository() { own := p.ownID() if ui.Button(c.Part("repo-back"), g.Back(p.repositoryName(own))).Ghost().Shrink(0).Clicked() { c.After(func() { a.setLogRepo(p, own, "", "") }) @@ -692,7 +781,7 @@ func (a *App) drawLogList(c ui.C, p *project) { } } total := n - if l.hasMore || l.loadingMore { + if l.hasMore || l.loadingMore || l.limitReached { total++ } area := ui.List(c, &v.commits, total, func(row ui.ListRow) { a.drawLogRow(c, p, rows, row) }).Scrollbars().Grow(1).FillWidth() @@ -730,7 +819,8 @@ func (a *App) drawLogRow(c ui.C, p *project, rows []core.GraphRow, row ui.ListRo box.Draw(v.rowPainter(a, i)) } -// drawLogFooter declares the row under the list that loads the next page. +// drawLogFooter declares the row under the list that loads the next page, or that says the log +// read as many commits as its settings let it and offers them. func (a *App) drawLogFooter(c ui.C, p *project, row ui.ListRow) { l, g := &p.log, a.text.Git row.Element.Height(logRowHeight * 1.5).FillWidth().Items(ui.Center).Gap(8).PadX(12).Children(func() { @@ -746,6 +836,11 @@ func (a *App) drawLogFooter(c ui.C, p *project, row ui.ListRow) { a.loadMoreLog(p) }) } + case l.limitReached && !l.hasMore: + ui.Text(c, g.LimitReached(len(l.commits))).Muted() + if ui.Button(c.Part("adjust-limit"), g.AdjustLimit).Ghost().Clicked() { + c.After(a.openGitLogLimitSettings) + } default: if ui.Button(c.Part("load-more"), g.LoadMore).Ghost().Clicked() { c.After(func() { a.loadMoreLog(p) }) diff --git a/desktop/internal/workbench/gitpush_workspace.go b/desktop/internal/workbench/gitpush_workspace.go new file mode 100644 index 0000000000..5af6403303 --- /dev/null +++ b/desktop/internal/workbench/gitpush_workspace.go @@ -0,0 +1,401 @@ +package workbench + +import ( + "context" + "errors" + "fmt" + "path/filepath" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" +) + +// This file keeps the state and the actions of the Push Commits dialog of a workspace, which +// opens after Commit and Push as IDEA's Push dialog does: every repository of the commit with +// the branch it would push, its destination and the commits that remote lacks, the changed files +// of the selected commit, and the tag option. Core reviews every repository and orders the list +// (git.workspacePushPreview); the dialog pushes the checked ones in that order, each against its +// own reviewed preview, and skips a repository whose recorded submodule failed to push. + +// workspacePushTagChoices are the choices of the dialog's tag select once Push tags is on: the +// tags of the pushed branch, which IDEA calls Current Branch, or all of them. +var workspacePushTagChoices = []core.GitPushTags{core.GitPushTagsReachable, core.GitPushTagsAll} + +// workspacePushKernel is what the dialog asks of the kernel; a kernel without it offers no dialog, +// and Commit and Push then only commits. +type workspacePushKernel interface { + WorkspacePushPreview(ctx context.Context, repositories []core.WorkspaceCommitRepository, tags core.GitPushTags, targets map[string]core.PushTargetChoice) ([]core.WorkspacePushRepository, error) + GitPushInWorkspace(ctx context.Context, root string, preview core.GitPushPreview, tags core.GitPushTags, target core.PushTargetChoice) error + GitCommitFiles(ctx context.Context, root, commit string) ([]core.GitCommitFile, error) + changedFileGrouper +} + +// workspacePushState is the open Push Commits dialog. +type workspacePushState struct { + open bool + loading bool + gen int + // err is why the last review failed as a whole. + err string + // bindings are the repositories the dialog reviews and names the name each shows. + bindings []core.WorkspaceCommitRepository + names map[string]string + // repos is Core's review in push order. + repos []core.WorkspacePushRepository + // checked are the repositories the user checked. prefer are the ones checked once the first + // review arrives, among those ready to push; nil checks every ready one. + checked map[string]bool + prefer map[string]bool + reviewed bool + // folded are the repositories whose commits the list hides under their row. + folded map[string]bool + // targets answer divergent upstreams by repository ID. + targets map[string]core.PushTargetChoice + // tagsOn is the Push tags checkbox, and tags indexes workspacePushTagChoices. + tagsOn bool + tags int + // selRepo and selCommit are the selected commit, whose files the right side lists. + selRepo string + selCommit string + files savedFiles + filesGen int + filesErr string + fileState logFiles + // outcomes are how the last push went for each repository it reached. + outcomes map[string]workspacePushOutcome + // busy is set while the pushes run. + busy bool +} + +// workspacePushOutcome is how one repository's push went. +type workspacePushOutcome struct { + pushed bool + // skippedFor is the submodule whose failed push kept this repository from pushing. + skippedFor string + err string +} + +// workspacePushStep is one push of a run: the repository, where it runs, and what it was +// reviewed against. +type workspacePushStep struct { + id, root string + preview core.GitPushPreview + target core.PushTargetChoice + records []string +} + +// workspacePusher is the window's kernel as the dialog uses it. +func (a *App) workspacePusher() (workspacePushKernel, bool) { + k, ok := a.kernel.(workspacePushKernel) + return k, ok +} + +// openWorkspacePush opens the Push Commits dialog on bindings, checking the ready repositories +// among prefer, every ready one when prefer is empty. names gives each binding's label. +func (a *App) openWorkspacePush(p *project, bindings []core.WorkspaceCommitRepository, names map[string]string, prefer map[string]bool, surface actionSurface) { + if _, ok := a.workspacePusher(); !ok || len(bindings) == 0 { + return + } + s := &p.review.workspacePush + if s.busy { + return + } + if len(prefer) == 0 { + prefer = nil + } + *s = workspacePushState{ + open: true, gen: s.gen + 1, bindings: bindings, names: names, prefer: prefer, + checked: map[string]bool{}, folded: map[string]bool{}, targets: map[string]core.PushTargetChoice{}, + } + a.performed("git.workspacePush.open", surface) + a.loadWorkspacePush(p) +} + +// closeWorkspacePush closes the dialog; it stays open while the pushes run. +func (a *App) closeWorkspacePush(p *project) { + s := &p.review.workspacePush + if s.busy { + return + } + s.open = false + s.gen++ + s.filesGen++ +} + +// pushTags is the tag scope of the dialog's pushes. +func (s *workspacePushState) pushTags() core.GitPushTags { + if !s.tagsOn { + return core.GitPushTagsNone + } + return workspacePushTagChoices[s.tags] +} + +// loadWorkspacePush reads Core's review with the choices made so far. +func (a *App) loadWorkspacePush(p *project) { + kernel, ok := a.workspacePusher() + if !ok { + return + } + s := &p.review.workspacePush + s.loading, s.err, s.gen = true, "", s.gen+1 + gen, bindings, tags := s.gen, s.bindings, s.pushTags() + targets := make(map[string]core.PushTargetChoice, len(s.targets)) + for id, target := range s.targets { + targets[id] = target + } + a.background(p, reviewTimeout, func(ctx context.Context) func(*App) { + repos, err := kernel.WorkspacePushPreview(ctx, bindings, tags, targets) + return func(a *App) { + s := &p.review.workspacePush + if !s.open || s.gen != gen { + return + } + s.loading = false + if err != nil { + s.err = i18n.Shared(a.language(), "git.pushDialog.previewFailed") + " " + reviewReason(err) + a.operationFailed("git_workspace_push_preview", err) + return + } + s.repos = repos + a.reviewedWorkspacePush(p) + } + }) +} + +// reviewedWorkspacePush applies a new review: the first one checks the preferred repositories, +// every one drops the checks of repositories that can no longer push, and the selection moves +// to the first commit when its own is gone. +func (a *App) reviewedWorkspacePush(p *project) { + s := &p.review.workspacePush + for _, repo := range s.repos { + switch { + case repo.State != core.WorkspacePushReady: + delete(s.checked, repo.ID) + case !s.reviewed: + s.checked[repo.ID] = s.prefer == nil || s.prefer[repo.ID] + } + } + s.reviewed = true + if _, ok := s.commit(s.selRepo, s.selCommit); ok { + return + } + for _, repo := range s.repos { + if repo.Preview != nil && len(repo.Preview.Commits) > 0 && s.checked[repo.ID] { + a.selectWorkspacePushCommit(p, repo.ID, repo.Preview.Commits[0].Hash) + return + } + } + s.selRepo, s.selCommit = "", "" + s.files.reset() + s.fileState = logFilesIdle +} + +// commit is the listed commit hash of the repository id. +func (s *workspacePushState) commit(id, hash string) (core.GitCommit, bool) { + if hash == "" { + return core.GitCommit{}, false + } + for _, repo := range s.repos { + if repo.ID != id || repo.Preview == nil { + continue + } + for _, commit := range repo.Preview.Commits { + if commit.Hash == hash { + return commit, true + } + } + } + return core.GitCommit{}, false +} + +// rootOf is where the repository id runs. +func (s *workspacePushState) rootOf(id string) string { + for _, binding := range s.bindings { + if binding.ID == id { + return binding.Root + } + } + return "" +} + +// nameOf is the label of the repository id. +func (s *workspacePushState) nameOf(id string) string { + if name := s.names[id]; name != "" { + return name + } + if id == commitRepositoryID { + return filepath.Base(s.rootOf(id)) + } + return id +} + +// selectWorkspacePushCommit selects a commit of the repository id and reads its changed files. +func (a *App) selectWorkspacePushCommit(p *project, id, hash string) { + kernel, ok := a.workspacePusher() + if !ok { + return + } + s := &p.review.workspacePush + if s.selRepo == id && s.selCommit == hash && s.fileState != logFilesIdle { + return + } + s.selRepo, s.selCommit = id, hash + s.filesGen++ + s.fileState, s.filesErr = logFilesLoading, "" + s.files.reset() + gen, root := s.filesGen, s.rootOf(id) + a.background(p, reviewTimeout, func(ctx context.Context) func(*App) { + files, err := kernel.GitCommitFiles(ctx, root, hash) + var layer savedLayer + if err == nil { + changed := make([]core.GitDiffFile, len(files)) + for i, file := range files { + changed[i] = core.GitDiffFile{Path: file.Path, Status: file.Status} + } + layer, err = newSavedLayer(ctx, kernel, "", changed) + } + return func(a *App) { + s := &p.review.workspacePush + if !s.open || s.filesGen != gen { + return + } + if err != nil { + s.fileState, s.filesErr = logFilesFailed, reviewReason(err) + a.operationFailed("git_commit_files", err) + return + } + s.files.reset(layer) + s.fileState = logFilesReady + } + }) +} + +// openWorkspacePushFile opens the diff of a changed file of the selected commit. +func (a *App) openWorkspacePushFile(p *project, path string) { + s := &p.review.workspacePush + if s.selCommit == "" { + return + } + root := s.rootOf(s.selRepo) + for _, layer := range s.files.layers { + for _, file := range layer.files { + if file.Path == path { + a.openCommitDiff(p, root, s.selCommit, core.GitCommitFile{Path: file.Path, Status: file.Status}) + return + } + } + } +} + +// chooseWorkspacePushTarget answers the divergent upstream of the repository id and reviews +// again with it. +func (a *App) chooseWorkspacePushTarget(p *project, id string, target core.PushTargetChoice) { + s := &p.review.workspacePush + if s.busy { + return + } + s.targets[id] = target + a.loadWorkspacePush(p) +} + +// workspacePushSteps are the checked repositories that can push, in Core's order. +func (s *workspacePushState) workspacePushSteps() []workspacePushStep { + var steps []workspacePushStep + for _, repo := range s.repos { + if !s.checked[repo.ID] || repo.State != core.WorkspacePushReady || repo.Preview == nil { + continue + } + steps = append(steps, workspacePushStep{ + id: repo.ID, root: s.rootOf(repo.ID), preview: *repo.Preview, + target: s.targets[repo.ID], records: repo.Records, + }) + } + return steps +} + +// canPushWorkspace reports that the checked repositories may be pushed: at least one is +// checked, and each checked divergent upstream has a destination. +func (s *workspacePushState) canPushWorkspace() bool { + if s.loading || s.busy || !s.reviewed { + return false + } + any := false + for _, repo := range s.repos { + if !s.checked[repo.ID] || repo.State != core.WorkspacePushReady { + continue + } + if repo.NeedsTarget { + return false + } + any = true + } + return any +} + +// submitWorkspacePush pushes the checked repositories one after another in Core's order. A +// repository whose recorded submodule did not push is skipped, since Git would refuse it. +func (a *App) submitWorkspacePush(p *project) { + s := &p.review.workspacePush + if !s.canPushWorkspace() || p.log.sync.busy { + return + } + steps, tags := s.workspacePushSteps(), s.pushTags() + a.performed("git.workspacePush", surfaceButton) + s.busy, s.outcomes = true, map[string]workspacePushOutcome{} + outcomes := map[string]workspacePushOutcome{} + // The dialog stays open on a failure and shows each repository's reason under its row. + a.runSyncAt(p, p.root, "git_push", i18n.Shared(a.language(), "git.pushing"), func(string) string { + return i18n.Shared(a.language(), "desktop.git.pushAll.someFailed") + }, func(ctx context.Context, kernel Kernel, _ string) (func(*App), error) { + pusher, ok := kernel.(workspacePushKernel) + if !ok { + return nil, errors.New("push is not available") + } + var first error + for _, step := range steps { + if blocked := blockedBy(step, outcomes); blocked != "" { + outcomes[step.id] = workspacePushOutcome{skippedFor: blocked} + continue + } + if err := pusher.GitPushInWorkspace(ctx, step.root, step.preview, tags, step.target); err != nil { + outcomes[step.id] = workspacePushOutcome{err: syncReason(err)} + if first == nil { + first = fmt.Errorf("%s: %w", step.id, err) + } + if errors.Is(err, context.Canceled) { + return nil, err + } + continue + } + outcomes[step.id] = workspacePushOutcome{pushed: true} + } + if first != nil { + return nil, first + } + return func(a *App) { a.notifySuccess(i18n.Shared(a.language(), "git.changesPushed")) }, nil + }) + // The dialog follows the outcome: it closes once everything pushed, and otherwise shows how + // each repository went and reviews the repositories as they are now. + p.log.sync.done = func(a *App, err error) { + s := &p.review.workspacePush + s.busy = false + s.outcomes = outcomes + a.loadNestedRepos(p) + if err == nil { + a.closeWorkspacePush(p) + return + } + a.loadWorkspacePush(p) + } +} + +// blockedBy is the recorded submodule of step whose push did not succeed in this run, empty +// when none failed. +func blockedBy(step workspacePushStep, outcomes map[string]workspacePushOutcome) string { + for _, child := range step.records { + if outcome, ok := outcomes[child]; ok && !outcome.pushed { + return child + } + } + return "" +} diff --git a/desktop/internal/workbench/gitpush_workspace_test.go b/desktop/internal/workbench/gitpush_workspace_test.go new file mode 100644 index 0000000000..c0d80f6a47 --- /dev/null +++ b/desktop/internal/workbench/gitpush_workspace_test.go @@ -0,0 +1,173 @@ +package workbench + +import ( + "os" + "path/filepath" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" +) + +// pushedRepository makes dir a repository on main with one commit, pushed to a bare remote +// named origin under remotes, and returns the remote's path. +func pushedRepository(t *testing.T, dir, remotes, name string) string { + t.Helper() + if err := os.MkdirAll(dir, 0o700); err != nil { + t.Fatal(err) + } + gitRun(t, dir, "init") + gitRun(t, dir, "symbolic-ref", "HEAD", "refs/heads/main") + commitFile(t, dir, name+".txt", "initial") + remote := filepath.Join(remotes, name+".git") + gitRun(t, remotes, "init", "--bare", remote) + gitRun(t, dir, "remote", "add", "origin", remote) + gitRun(t, dir, "push", "-q", "-u", "origin", "main") + return remote +} + +// commitFile writes subject into name in dir and commits it with subject as the message. +func commitFile(t *testing.T, dir, name, subject string) { + t.Helper() + if err := os.WriteFile(filepath.Join(dir, name), []byte(subject+"\n"), 0o600); err != nil { + t.Fatal(err) + } + gitRun(t, dir, "add", name) + gitRun(t, dir, "commit", "-q", "-m", subject) +} + +// remoteHead is the commit main points at in the bare remote. +func remoteHead(t *testing.T, remote string) string { + t.Helper() + return gitRun(t, remote, "rev-parse", "refs/heads/main") +} + +// awaitWorkspacePush waits until the Push Commits dialog shows a review and nothing runs. +func (h *harness) awaitWorkspacePush(p *project) *workspacePushState { + h.t.Helper() + s := &p.review.workspacePush + h.await("the Push Commits review", func() bool { return s.open && s.reviewed && !s.loading && !s.busy }) + return s +} + +// Commit and Push commits first and then asks, as IDEA does, in the Push Commits dialog: the +// committed repository is checked with the commit listed, and Push sends it. +func TestCommitAndPushCommitsThenOpensThePushCommitsDialog(t *testing.T) { + requireTestGit(t) + root := t.TempDir() + dir := filepath.Join(root, "project") + remote := pushedRepository(t, dir, root, "project") + if err := os.WriteFile(filepath.Join(dir, "project.txt"), []byte("changed\n"), 0o600); err != nil { + t.Fatal(err) + } + h := newHarness(t, &gitKernel{Client: core.NewClient()}) + p := h.openCommit(dir) + h.stageAll(p) + p.commit.editor.Insert("Publish the change") + h.settle() + before := remoteHead(t, remote) + + h.clickNamed(h.app.text.Commit.CommitAndPush) + s := h.awaitWorkspacePush(p) + if got := gitRun(t, dir, "log", "-1", "--format=%s"); got != "Publish the change" { + t.Fatalf("last commit = %q, want the commit to run before the push is asked", got) + } + if remoteHead(t, remote) != before { + t.Fatal("the commit was pushed before the Push Commits dialog was confirmed") + } + if !s.checked[commitRepositoryID] || s.selCommit == "" { + t.Fatalf("checked %v, selected %q: want the committed repository checked and its commit selected", s.checked, s.selCommit) + } + lang := h.app.language() + for _, text := range []string{"Publish the change", "origin : main"} { + if !h.shows(text) { + t.Fatalf("the Push Commits dialog does not show %q", text) + } + } + h.await("the changed files", func() bool { return s.fileState == logFilesReady }) + if !h.shows("project.txt") { + t.Fatal("the Push Commits dialog does not list the selected commit's file") + } + + h.clickNamed(i18n.Shared(lang, "desktop.git.pushAll.push")) + h.await("the push", func() bool { return !s.busy && !s.open }) + if got, want := remoteHead(t, remote), gitRun(t, dir, "rev-parse", "HEAD"); got != want { + t.Fatalf("remote main = %s, want the pushed %s", got, want) + } +} + +// The dialog pushes a submodule before the repository that records it, and skips that +// repository when the submodule failed to push, since Git would refuse it. A repository without +// a remote shows that it needs one and cannot be checked. +func TestPushCommitsDialogPushesInOrderAndSkipsWhatAFailedSubmoduleBlocks(t *testing.T) { + requireTestGit(t) + root := t.TempDir() + parent := filepath.Join(root, "parent") + parentRemote := pushedRepository(t, parent, root, "parent") + child := filepath.Join(parent, "child") + childRemote := pushedRepository(t, child, root, "child") + commitFile(t, child, "child.txt", "child work") + gitRun(t, parent, "add", "child") + gitRun(t, parent, "commit", "-q", "-m", "record child") + local := filepath.Join(root, "local") + if err := os.MkdirAll(local, 0o700); err != nil { + t.Fatal(err) + } + gitRun(t, local, "init") + gitRun(t, local, "symbolic-ref", "HEAD", "refs/heads/main") + commitFile(t, local, "local.txt", "local work") + + h := newHarness(t, &gitKernel{Client: core.NewClient()}) + p := h.openCommit(parent) + bindings := []core.WorkspaceCommitRepository{ + {ID: commitRepositoryID, Root: parent}, {ID: "child", Root: child}, {ID: "local", Root: local}, + } + h.app.openWorkspacePush(p, bindings, map[string]string{commitRepositoryID: "parent"}, nil, surfaceButton) + s := h.awaitWorkspacePush(p) + var order []string + for _, repo := range s.repos { + order = append(order, repo.ID) + } + if len(order) != 3 || order[0] != "child" || order[1] != commitRepositoryID || order[2] != "local" { + t.Fatalf("listed %v, want the submodule before the repository that records it", order) + } + lang := h.app.language() + if !h.shows(i18n.Shared(lang, "desktop.git.pushAll.defineRemote")) || s.checked["local"] { + t.Fatal("the repository without a remote does not ask for one or is checked") + } + if !s.checked["child"] || !s.checked[commitRepositoryID] { + t.Fatalf("checked %v, want both ready repositories", s.checked) + } + parentBefore, childBefore := remoteHead(t, parentRemote), remoteHead(t, childRemote) + + // The child's remote goes away after the review: its push fails, and the parent, which + // records the child's new commit, is not pushed. + moved := childRemote + ".moved" + if err := os.Rename(childRemote, moved); err != nil { + t.Fatal(err) + } + h.clickNamed(i18n.Shared(lang, "desktop.git.pushAll.push")) + h.await("the failed push", func() bool { return len(s.outcomes) == 2 && !s.busy }) + if outcome := s.outcomes["child"]; outcome.pushed || outcome.err == "" { + t.Fatalf("child outcome = %+v, want its push to fail", outcome) + } + if outcome := s.outcomes[commitRepositoryID]; outcome.skippedFor != "child" { + t.Fatalf("parent outcome = %+v, want it skipped for the child", outcome) + } + if remoteHead(t, parentRemote) != parentBefore { + t.Fatal("the parent was pushed although the child it records was not") + } + if !s.open || h.app.notice != i18n.Shared(lang, "desktop.git.pushAll.someFailed") { + t.Fatalf("open %v, notice %q: want the dialog kept open with the failure noted", s.open, h.app.notice) + } + + if err := os.Rename(moved, childRemote); err != nil { + t.Fatal(err) + } + s = h.awaitWorkspacePush(p) + h.clickNamed(i18n.Shared(lang, "desktop.git.pushAll.push")) + h.await("the push", func() bool { return !s.busy && !s.open }) + if remoteHead(t, childRemote) == childBefore || remoteHead(t, parentRemote) == parentBefore { + t.Fatal("the second push did not send both repositories") + } +} diff --git a/desktop/internal/workbench/gitpush_workspace_view.go b/desktop/internal/workbench/gitpush_workspace_view.go new file mode 100644 index 0000000000..4afbff2fc1 --- /dev/null +++ b/desktop/internal/workbench/gitpush_workspace_view.go @@ -0,0 +1,284 @@ +package workbench + +import ( + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/icons" + "github.com/1lck/Lithe-IDEA/desktop/internal/treelist" + "github.com/vivaui/viva/gfx" + "github.com/vivaui/viva/ui" +) + +// This file declares the Push Commits dialog laid out as IDEA's: the repositories with their +// checkboxes, destinations and outgoing commits on the left, the changed files of the selected +// commit on the right, and the tag option under them. State and actions are in +// gitpush_workspace.go. + +// workspacePushFilesWidth is the width of the changed files side. +const workspacePushFilesWidth = 320 + +// workspacePushTagIndexes number the choices of the tag select. +var workspacePushTagIndexes = []int{0, 1} + +// drawWorkspacePushDialog declares the Push Commits dialog. +func (a *App) drawWorkspacePushDialog(c ui.C, p *project) { + s := &p.review.workspacePush + lang := a.language() + size := a.theme.Metrics.FontSizeS + open := true + spec := ui.ModalSpec{Description: i18n.Shared(lang, "desktop.git.pushAll.description"), Width: reviewDialogWidth, Height: reviewDialogHeight} + closed := ui.ModalWith(c, &open, i18n.Shared(lang, "desktop.git.pushAll.title"), spec, func() { + ui.Column(c).Fill().Gap(8).Children(func() { + switch { + case !s.reviewed && s.err != "": + ui.Paragraph(c, s.err, 4).FontSize(size).Color(a.theme.Danger) + return + case !s.reviewed: + a.gitEmpty(c, i18n.Shared(lang, "git.pushDialog.loading")) + return + case len(s.repos) == 0: + a.gitEmpty(c, i18n.Shared(lang, "desktop.git.pushAll.noRepositories")) + return + } + if s.err != "" { + ui.Paragraph(c, s.err, 3).FontSize(size).Color(a.theme.Danger) + } + ui.Row(c).FillWidth().Grow(1).Gap(8).Children(func() { + ui.Scroll(c.Part("repositories")).Scrollbars().Grow(1).FillHeight(). + Border(1, a.colors.Line).Radius(a.theme.Metrics.RadiusItem()).Children(func() { + ui.Column(c).FillWidth().Pad(2).Children(func() { + for _, repo := range s.repos { + a.drawWorkspacePushRepository(c.Key(repo.ID), p, repo) + } + }) + }) + ui.Column(c.Part("files")).Width(workspacePushFilesWidth).Shrink(0).FillHeight(). + Border(1, a.colors.Line).Radius(a.theme.Metrics.RadiusItem()).Children(func() { + a.drawWorkspacePushFiles(c, p) + }) + }) + ui.Row(c).FillWidth().Shrink(0).Items(ui.Center).Gap(8).Children(func() { + label := i18n.Shared(lang, "desktop.git.pushAll.pushTags") + if ui.Checkbox(c, &s.tagsOn, label).Disabled(s.busy).Clicked() { + c.After(func() { a.loadWorkspacePush(p) }) + } + names := []string{i18n.Shared(lang, "desktop.git.pushAll.tagsCurrentBranch"), i18n.Shared(lang, "desktop.git.pushAll.tagsAll")} + before := s.tags + ui.Select(c, &s.tags, workspacePushTagIndexes, func(i int) string { return names[i] }).Label(label).Disabled(s.busy || !s.tagsOn) + if s.tags != before { + c.After(func() { a.loadWorkspacePush(p) }) + } + ui.Spacer(c) + if s.busy { + if words := a.syncProgressWords(&p.log.sync); words != "" { + ui.Text(c, words).FontSize(size).Color(a.colors.Subtle).Ellipsis().Shrink(1) + } + if sync := &p.log.sync; sync.hasProgress && sync.progress.Percent != nil { + ui.Progress(c, float32(*sync.progress.Percent)/100).Width(syncProgressWidth) + } + } + }) + }) + }, func() { + if s.busy { + if ui.Button(c, a.text.Sync.Cancel).Outline().Clicked() { + c.After(func() { a.cancelSync(p) }) + } + return + } + if ui.Button(c, i18n.Shared(lang, "desktop.gitReview.cancel")).Outline().Clicked() { + open = false + } + if ui.Button(c, i18n.Shared(lang, "desktop.git.pushAll.push")).Disabled(!s.canPushWorkspace()).Clicked() { + c.After(func() { a.submitWorkspacePush(p) }) + } + }) + if (closed || !open) && !s.busy { + c.After(func() { a.closeWorkspacePush(p) }) + } +} + +// drawWorkspacePushRepository declares a repository's row, what its push needs or how it went, +// and the commits it would send under it. +func (a *App) drawWorkspacePushRepository(c ui.C, p *project, repo core.WorkspacePushRepository) { + s := &p.review.workspacePush + lang := a.language() + size := a.theme.Metrics.FontSizeS + commits := []core.GitCommit(nil) + if repo.Preview != nil { + commits = repo.Preview.Commits + } + name := s.nameOf(repo.ID) + ui.Row(c).FillWidth().Height(logItemHeight).Shrink(0).Items(ui.Center).Gap(treelist.Gap).PadX(4).Children(func() { + a.drawWorkspacePushFold(c, s, repo.ID, name, len(commits) > 0) + ready := repo.State == core.WorkspacePushReady + checked := ready && s.checked[repo.ID] + if a.treeCheckbox(c, &checked, name).Disabled(s.busy || !ready).Clicked() && ready { + id, value := repo.ID, checked + c.After(func() { s.checked[id] = value }) + } + ui.Text(c, name).FontSize(treeFontSize).Weight(gfx.WeightMedium).Ellipsis().Shrink(1) + a.drawWorkspacePushDestination(c, repo) + }) + indent := float32(treelist.Gutter + treelist.Disclosure + treelist.Gap) + if repo.NeedsTarget && repo.Preview != nil { + a.drawWorkspacePushTargetChoice(c, p, repo, indent) + } + if outcome, ok := s.outcomes[repo.ID]; ok { + text, color := i18n.Shared(lang, "desktop.git.pushAll.pushed"), a.colors.Success + switch { + case outcome.skippedFor != "": + text = i18n.SharedFormat(lang, "desktop.git.pushAll.skipped", map[string]string{"repository": s.nameOf(outcome.skippedFor)}) + color = a.colors.Warning + case outcome.err != "": + // Git's own reason is shown as it words it. + text, color = i18n.SharedFormat(lang, "desktop.git.pushAll.failed", map[string]string{"reason": outcome.err}), a.theme.Danger + } + ui.Paragraph(c.Part("outcome"), text, 3).FontSize(size).Color(color).PadLeft(indent) + } + if s.folded[repo.ID] { + return + } + for _, commit := range commits { + a.drawWorkspacePushCommit(c.Key(commit.Hash), p, repo.ID, commit, indent+float32(treelist.Indent)) + } + if repo.Preview != nil && repo.Preview.HasMore { + ui.Text(c.Part("more"), i18n.Shared(lang, "git.pushDialog.moreCommits")).FontSize(size).Muted().PadLeft(indent + float32(treelist.Indent)) + } +} + +// drawWorkspacePushFold declares the arrow that shows or hides a repository's commits; a +// repository without commits keeps the arrow's room so the checkboxes line up. +func (a *App) drawWorkspacePushFold(c ui.C, s *workspacePushState, id, name string, foldable bool) { + k := c.Part("fold") + if !foldable { + ui.Row(k).Size(treelist.Disclosure, treelist.Icon).Shrink(0) + return + } + open := !s.folded[id] + label, chevron := i18n.Shared(a.language(), "native.collapseDirectory"), icons.ChevronDown + if !open { + label, chevron = i18n.Shared(a.language(), "native.expandDirectory"), icons.ChevronRight + } + slot := ui.Row(k).Size(treelist.Disclosure, treelist.Icon).Shrink(0).Center(). + HitWith(ui.ID(k), label+" "+name, gfx.HitOptions{Role: gfx.RoleButton, Cursor: gfx.PointerCursorHand, Expandable: true, Expanded: open, SkipFocus: true}) + slot.Children(func() { + ui.Icon(k, chevron).Size(12, 12).Color(a.colors.Subtle) + }) + if slot.Clicked() { + c.After(func() { s.folded[id] = open }) + } +} + +// drawWorkspacePushDestination declares where a repository's branch would go, or why it cannot +// push, after its name: IDEA's "main → origin : main". +func (a *App) drawWorkspacePushDestination(c ui.C, repo core.WorkspacePushRepository) { + lang := a.language() + size := a.theme.Metrics.FontSizeS + muted := func(text string) { + ui.Text(c, text).FontSize(size).Color(a.colors.Subtle).Ellipsis().Shrink(1) + } + switch repo.State { + case core.WorkspacePushReady, core.WorkspacePushUpToDate: + pv := repo.Preview + if pv == nil { + return + } + ui.Text(c, pv.LocalBranch).FontSize(size).Shrink(0) + ui.Text(c, "→").FontSize(size).Color(a.colors.Subtle).Shrink(0) + ui.Text(c, pv.Remote+" : "+pv.RemoteBranch).FontSize(size).Color(a.colors.Accent).Ellipsis().Shrink(1) + if pv.CreatesRemoteBranch { + ui.Text(c, i18n.Shared(lang, "git.pushDialog.createsRemoteBranch")).FontSize(size).Color(a.colors.Success).Shrink(0) + } + if repo.State == core.WorkspacePushUpToDate { + muted(i18n.Shared(lang, "desktop.git.pushAll.upToDate")) + } + case core.WorkspacePushNoRemote: + if repo.Branch != "" { + ui.Text(c, repo.Branch).FontSize(size).Shrink(0) + ui.Text(c, "→").FontSize(size).Color(a.colors.Subtle).Shrink(0) + } + ui.Text(c, i18n.Shared(lang, "desktop.git.pushAll.defineRemote")).FontSize(size).Color(a.colors.Accent).Shrink(0) + case core.WorkspacePushEmpty: + muted(i18n.Shared(lang, "desktop.git.pushAll.emptyRepository")) + case core.WorkspacePushDetached: + muted(i18n.Shared(lang, "desktop.git.pushAll.detachedHead")) + default: + // Core's detail is Git's own diagnostic, shown as it words it. + ui.Text(c, i18n.SharedFormat(lang, "desktop.git.pushAll.readFailed", map[string]string{"reason": repo.Detail})). + FontSize(size).Color(a.theme.Danger).Ellipsis().Shrink(1) + } +} + +// drawWorkspacePushTargetChoice declares the choice a divergent upstream needs: publish under +// the branch's own name, or push to the upstream it tracks. +func (a *App) drawWorkspacePushTargetChoice(c ui.C, p *project, repo core.WorkspacePushRepository, indent float32) { + s := &p.review.workspacePush + lang := a.language() + size := a.theme.Metrics.FontSizeS + pv := repo.Preview + upstream := "" + if pv.Upstream != nil { + upstream = *pv.Upstream + } + ui.Column(c.Part("target")).FillWidth().Shrink(0).Gap(2).PadLeft(indent).Children(func() { + ui.Paragraph(c, i18n.SharedFormat(lang, "git.pushDialog.divergentWarning", map[string]string{"branch": pv.LocalBranch, "upstream": upstream}), 3). + FontSize(size).Color(a.colors.Warning) + ui.Row(c).FillWidth().Shrink(0).Gap(8).Children(func() { + id := repo.ID + publish := s.targets[id] == core.PushTargetPublish + if ui.Checkbox(c, &publish, i18n.SharedFormat(lang, "git.pushDialog.publishSameName", map[string]string{"remote": pv.Remote, "branch": pv.LocalBranch})).Disabled(s.busy).Clicked() { + c.After(func() { a.chooseWorkspacePushTarget(p, id, core.PushTargetPublish) }) + } + toUpstream := s.targets[id] == core.PushTargetUpstream + if ui.Checkbox(c, &toUpstream, i18n.SharedFormat(lang, "git.pushDialog.pushToUpstream", map[string]string{"branch": upstream})).Disabled(s.busy).Clicked() { + c.After(func() { a.chooseWorkspacePushTarget(p, id, core.PushTargetUpstream) }) + } + }) + }) +} + +// drawWorkspacePushCommit declares one outgoing commit; clicking it lists its changed files. +func (a *App) drawWorkspacePushCommit(c ui.C, p *project, id string, commit core.GitCommit, indent float32) { + s := &p.review.workspacePush + size := a.theme.Metrics.FontSizeS + selected := s.selRepo == id && s.selCommit == commit.Hash + row := ui.Row(c).FillWidth().Height(reviewRowHeight+2).Shrink(0).Items(ui.Center).Gap(8). + PadSides(0, 8, 0, indent).Radius(a.theme.Metrics.RadiusItem()). + HitWith(ui.ID(c), commit.Subject, gfx.HitOptions{Cursor: gfx.PointerCursorHand}) + if selected { + row = row.Background(a.colors.Selection) + } else { + row = row.Hover(ui.Look{}.Background(a.colors.Hover)) + } + row.Children(func() { + ui.Text(c, commit.Subject).FontSize(treeFontSize).Ellipsis().Grow(1) + ui.Text(c, commit.ShortHash).Mono().FontSize(size).Color(a.colors.Subtle).Shrink(0) + }) + if row.Clicked() { + hash := commit.Hash + c.After(func() { a.selectWorkspacePushCommit(p, id, hash) }) + } +} + +// drawWorkspacePushFiles declares the changed files of the selected commit; opening one shows +// its diff in that commit. +func (a *App) drawWorkspacePushFiles(c ui.C, p *project) { + s := &p.review.workspacePush + lang := a.language() + switch s.fileState { + case logFilesIdle: + a.gitEmpty(c, i18n.Shared(lang, "desktop.git.pushAll.noCommitSelected")) + case logFilesLoading: + a.gitEmpty(c, i18n.Shared(lang, "desktop.git.pushAll.loadingFiles")) + case logFilesFailed: + ui.Paragraph(c, i18n.SharedFormat(lang, "desktop.git.pushAll.filesFailed", map[string]string{"reason": s.filesErr}), 4). + FontSize(a.theme.Metrics.FontSizeS).Color(a.theme.Danger).Pad(8) + default: + if s.files.empty() { + a.gitEmpty(c, i18n.Shared(lang, "desktop.git.pushAll.noChangedFiles")) + return + } + a.drawSavedFileList(c, &s.files, func(file savedPath) { a.openWorkspacePushFile(p, file.path) }) + } +} diff --git a/desktop/internal/workbench/gitreview.go b/desktop/internal/workbench/gitreview.go index 49462c76b2..483cdd503a 100644 --- a/desktop/internal/workbench/gitreview.go +++ b/desktop/internal/workbench/gitreview.go @@ -69,6 +69,8 @@ type gitReview struct { blame blameState untracked untrackedState rollback rollbackState + // workspacePush is the Push Commits dialog Commit and Push opens (gitpush_workspace.go). + workspacePush workspacePushState } // reviewReason is the line of err to show: Git's own first line when Core gave one. diff --git a/desktop/internal/workbench/gitreview_diff_view.go b/desktop/internal/workbench/gitreview_diff_view.go index cf9eb52ce1..1cb72dcc51 100644 --- a/desktop/internal/workbench/gitreview_diff_view.go +++ b/desktop/internal/workbench/gitreview_diff_view.go @@ -28,6 +28,9 @@ func (a *App) reviewOverlays(c ui.C, p *project) { if r.push.open { a.drawPushDialog(c, p) } + if r.workspacePush.open { + a.drawWorkspacePushDialog(c, p) + } if r.tools.open { a.drawToolsDialog(c, p) } diff --git a/desktop/internal/workbench/gitworktree.go b/desktop/internal/workbench/gitworktree.go index 40836ff49c..881a8bdf98 100644 --- a/desktop/internal/workbench/gitworktree.go +++ b/desktop/internal/workbench/gitworktree.go @@ -621,7 +621,7 @@ func (a *App) readWorktreeHistory(p *project, cursor string) { remotes, current = remoteNames(sections), branch } } - page, err := kernel.GitHistoryPage(ctx, path, "HEAD", cursor, worktreeHistoryPage) + page, err := kernel.GitHistoryPage(ctx, path, "HEAD", cursor, worktreeHistoryPage, 0) var graph core.Graph var graphErr error if err == nil { diff --git a/desktop/internal/workbench/gitworktree_test.go b/desktop/internal/workbench/gitworktree_test.go index a515b89821..b5be1f4485 100644 --- a/desktop/internal/workbench/gitworktree_test.go +++ b/desktop/internal/workbench/gitworktree_test.go @@ -583,12 +583,19 @@ func TestWorktreeChangesShareTheProjectsCommit(t *testing.T) { target.state.editor.Insert("Publish linked work") h.settle() h.clickNamed(commit.CommitAndPush) - h.await("the review", func() bool { return !target.state.busy && target.state.review != nil }) - if got := gitRun(t, linked, "log", "-1", "--format=%s"); got != "initial" { - t.Fatalf("the commit ran before its review was confirmed: %q", got) + push := &p.review.workspacePush + h.await("the Push Commits dialog", func() bool { return !target.state.busy && push.open && push.reviewed }) + if got := gitRun(t, linked, "log", "-1", "--format=%s"); got != "Publish linked work" { + t.Fatalf("last commit of the linked checkout = %q, want the one Commit and Push made", got) } - h.clickNamed(commit.Cancel) - if target.state.review != nil { - t.Fatal("cancel left the linked checkout's review open") + if got := gitRun(t, primary, "log", "-1", "--format=%s"); got == "Publish linked work" { + t.Fatal("the linked checkout's commit landed in the project's checkout") + } + if len(push.bindings) != 1 || push.rootOf(commitRepositoryID) != linked { + t.Fatalf("the Push Commits dialog reviews %+v, want the linked checkout", push.bindings) + } + h.clickNamed(i18n.Shared(h.app.language(), "desktop.gitReview.cancel")) + if push.open { + t.Fatal("cancel left the Push Commits dialog open") } } diff --git a/desktop/internal/workbench/gitworktree_view.go b/desktop/internal/workbench/gitworktree_view.go index c38e656c1b..ed7462a053 100644 --- a/desktop/internal/workbench/gitworktree_view.go +++ b/desktop/internal/workbench/gitworktree_view.go @@ -484,7 +484,7 @@ func (a *App) drawWorktreeChanges(c ui.C, p *project, w core.GitWorktree) { // drawWorktreeChange declares the row of one local change of the worktree at root, with the // commit panel's checkbox; a double click shows its diff. func (a *App) drawWorktreeChange(c ui.C, p *project, root string, busy bool, change core.GitChange) { - toggled, opened, _, _ := a.drawChangeRow(c, change, busy, false, changeRowIndent, func(rowC ui.C) func(*ui.MenuItems) { + toggled, opened, _, _ := a.drawChangeRow(c, change, busy, false, a.changeRowIndent(), func(rowC ui.C) func(*ui.MenuItems) { return a.worktreeChangeMenuItems(rowC, p, root, change) }) if toggled { diff --git a/desktop/internal/workbench/nested_refs.go b/desktop/internal/workbench/nested_refs.go index 5f5cfe6ba5..0fb5a3318a 100644 --- a/desktop/internal/workbench/nested_refs.go +++ b/desktop/internal/workbench/nested_refs.go @@ -2,7 +2,6 @@ package workbench import ( "context" - "strings" "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/vivaui/viva/gfx" @@ -10,17 +9,19 @@ import ( ) // This file is the references and the colors of the repositories of the project folder (matrix id -// git-multi-repository-references). The Git Log's reference pane lists, below its own sections, a -// group per repository the log does not walk, in Core's order and in each repository's color from -// Core; a click on a group or one of its references makes that repository the one the log walks -// (git_log_repo.go). The references are read with the log and again with the repositories; the -// colors are assigned with the repositories (nested_repos.go) and mark each repository in the branch -// popup, the change list, the Paths filter and the log rows. - -// nestedReferences are the references of one repository as the pane last read them. +// git-multi-repository-references). In a folder with several repositories the Git Log's reference +// pane lists, below HEAD, a node per repository in Core's order and in each repository's color from +// Core, each with its own local, remote and tag sections; a click on another repository's reference +// walks that reference in its repository (git_log_repo.go). The references of the repository the log +// reads its references with come with the history; the others are read with the log and again with +// the repositories. The colors are assigned with the repositories (nested_repos.go) and mark each +// repository in the branch popup, the change list, the Paths filter and the log rows. + +// nestedReferences are the references of one repository as the pane last read them, in the +// sections of its node. type nestedReferences struct { - refs core.GitReferences - err error + sections [3]logSection + err error } // repositoryColorer is the part of the kernel that assigns the repository colors. Core's client @@ -35,9 +36,9 @@ const repositoryColorPage = 128 // repositorySwatchSize is the side of the square that marks a repository in its color. const repositorySwatchSize = 10 -// loadNestedReferences reads in the background the references of the repositories the log does not -// walk, the groups of the reference pane. The answer of a reading that a newer one overtook is -// dropped. +// loadNestedReferences reads in the background the references of the repositories besides the +// one whose references the log reads with its history: the nodes of the reference pane. The answer +// of a reading that a newer one overtook is dropped. func (a *App) loadNestedReferences(p *project) { kernel := a.kernel n := &p.nested @@ -45,9 +46,10 @@ func (a *App) loadNestedReferences(p *project) { gen := n.refGen type read struct{ id, root string } var reads []read - for _, id := range n.others { - if root := p.rootOf(id); root != "" { - reads = append(reads, read{id: id, root: root}) + active := p.logRepoID() + for _, repo := range p.workspaceRepositories() { + if repo.id != active { + reads = append(reads, read{id: repo.id, root: repo.root}) } } a.background(p, gitTimeout, func(ctx context.Context) func(*App) { @@ -56,8 +58,8 @@ func (a *App) loadNestedReferences(p *project) { ctx = core.WithQueryCategory(ctx, core.GitQueryReferences) out := make(map[string]nestedReferences, len(reads)) for _, r := range reads { - refs, err := kernel.GitReferences(ctx, r.root) - out[r.id] = nestedReferences{refs: refs, err: err} + _, sections, _, err := readReferences(ctx, kernel, r.root) + out[r.id] = nestedReferences{sections: sections, err: err} } return func(a *App) { if p.nested.refGen == gen { @@ -147,44 +149,55 @@ func repositoryColor(slot int, dark bool) gfx.Color { return pick(dark, pair[0], pair[1]) } -// appendNestedLogRows appends the groups of the other repositories to the reference pane: one row -// per repository with local branches or tags, then those references. A click on a group or a -// reference makes its repository the one the log walks. While the filter has text only the matching -// references show, and every group opens. It returns how many references the groups list. -func (a *App) appendNestedLogRows(rows []logRefRow, p *project, query string) ([]logRefRow, int) { +// appendRepositoryLogRows appends a node per repository of the project folder to the reference +// pane, in Core's order, each with its own sections of local branches, remote branches and tags, as +// IDEA's branches pane groups a project with several roots. The references of the repository whose +// history the log reads its references with act on it; a click on another repository's reference +// walks that reference in its repository. While the filter has text only the matching references +// show, and every node opens. It returns how many references the nodes list. +func (a *App) appendRepositoryLogRows(rows []logRefRow, p *project, query string) ([]logRefRow, int) { shown := 0 - for _, id := range p.nested.others { - refs, loaded := p.nested.references[id] - if !loaded || refs.err != nil { - continue - } - var matches []core.GitReference - for _, r := range refs.refs.References { - if r.Kind != "local" && r.Kind != "tag" { + active := p.logRepoID() + for _, repo := range p.workspaceRepositories() { + sections, foreign := &p.log.sections, "" + if repo.id != active { + refs, loaded := p.nested.references[repo.id] + if !loaded || refs.err != nil { continue } - if query != "" && !strings.Contains(strings.ToLower(r.ShortName), query) { - continue - } - matches = append(matches, r) - } - if len(matches) == 0 { - continue + sections, foreign = &refs.sections, repo.id } - shown += len(matches) - key := "nested/" + id + key := logRepoRefKey(repo.id) open := query != "" || !p.log.collapsed[key] + node := len(rows) rows = append(rows, logRefRow{ - kind: logRefRepository, label: p.repositoryName(id), short: id, repo: id, key: key, open: open, - tint: a.repositoryTint(p, id), + kind: logRefRepository, label: repo.name, short: repo.id, repo: repo.id, key: key, open: open, + tint: a.repositoryTint(p, repo.id), }) - if !open { - continue + var count int + if open { + rows, count = a.appendLogSections(rows, p, key+"/", foreign, sections, 1, query) + } else { + count = sectionRefCount(sections) } - for i := range matches { - ref := &matches[i] - rows = append(rows, logRefRow{kind: logRefForeign, depth: 1, label: ref.ShortName, key: ref.FullName, short: ref.ShortName, ref: ref, repo: id}) + if query != "" && count == 0 { + rows = rows[:node] + continue } + shown += count } return rows, shown } + +// logRepoRefKey is the key of a repository's node in the reference pane; its sections and folders +// are keyed under it. +func logRepoRefKey(id string) string { return "r/" + id } + +// sectionRefCount is how many references sections hold. +func sectionRefCount(sections *[3]logSection) int { + n := 0 + for i := range sections { + n += len(sections[i].refs) + } + return n +} diff --git a/desktop/internal/workbench/nested_repos.go b/desktop/internal/workbench/nested_repos.go index 098b92f81c..4d9dc4c7f9 100644 --- a/desktop/internal/workbench/nested_repos.go +++ b/desktop/internal/workbench/nested_repos.go @@ -57,6 +57,9 @@ type nestedState struct { // logRepo is the ID of the nested repository the Git log walks; empty for the project's own // repository (git_log_repo.go). logRepo string + // chosen are the Core IDs of the repositories the Git log walks together, in Core's order, + // the first of them logRepo's; nil while it walks one (gitlog_multi.go). + chosen []string // refGen counts the reference readings; references are the last ones by repository ID // (nested_refs.go). refGen int @@ -66,8 +69,10 @@ type nestedState struct { slots map[string]int showColors bool // folded are the repositories whose changes the Commit window hides under their header; a - // group shows unfolded until it is folded (nested_repos_view.go). - folded map[string]bool + // group shows unfolded until it is folded (nested_repos_view.go). listFolded hides every + // group under the line of the change list. + folded map[string]bool + listFolded bool } // loadNestedRepos reads the repositories of the project folder, the status of each nested one and @@ -399,22 +404,3 @@ func (a *App) stageWorkspace(p *project, plan core.WorkspaceStageAll) { return func(a *App) { a.stagingDone(p, stage, err) } }) } - -// nestedCommitTarget is the commit of one nested repository: it commits the staged changes of -// that repository alone, with the message the Commit tool window holds. -func (a *App) nestedCommitTarget(p *project, repo nestedRepo) commitTarget { - return commitTarget{ - state: &p.commit, - root: repo.root, - repoID: repo.id, - written: func(a *App) { - a.reloadGit(p) - }, - } -} - -// canCommitNested reports that the commit button of repo may start a commit of its staged changes. -func (p *project) canCommitNested(repo nestedRepo) bool { - return !p.lists.inUse() && p.listsReady() && p.commit.idle() && !p.commit.busy && - countStaged(repo.changes) > 0 && p.commit.message() != "" -} diff --git a/desktop/internal/workbench/nested_repos_view.go b/desktop/internal/workbench/nested_repos_view.go index 5f3ec981d2..faf39f3f7b 100644 --- a/desktop/internal/workbench/nested_repos_view.go +++ b/desktop/internal/workbench/nested_repos_view.go @@ -8,15 +8,11 @@ import ( "github.com/vivaui/viva/ui" ) -// repositoryGroupGap is the space between the parts of a repository group's line; the rows of the -// group's changes are indented after it (repositoryChangeIndent). -const repositoryGroupGap = 6 - // drawRepositoryChanges declares the change list of a workspace with nested repositories as Core -// groups it: one line for all the changes, then a foldable group per repository with changes, in -// Core's order. A group is named after its repository, so a workspace where only one repository has -// changes still shows its name. What each checkbox writes is Core's plan; state and staging are in -// nested_repos.go. +// groups it: one foldable line for all the changes, then a foldable group per repository with +// changes, in Core's order, on the grid of the change tree (commit_view.go). A group is named +// after its repository, so a workspace where only one repository has changes still shows its +// name. What each checkbox writes is Core's plan; state and staging are in nested_repos.go. func (a *App) drawRepositoryChanges(c ui.C, p *project) { t := a.text.Commit n := &p.nested @@ -33,11 +29,14 @@ func (a *App) drawRepositoryChanges(c ui.C, p *project) { return } ui.Scroll(c).Scrollbars().Grow(1).FillWidth().PadY(4).Children(func() { - a.drawChangeListHeader(c, t.ChangeList, t.Files(g.FileCount), g.AllStaged, g.StageAll != nil, p.commit.busy, func() { + a.drawChangeListHeader(c, t.ChangeList, t.Files(g.FileCount), g.AllStaged, g.StageAll != nil, p.commit.busy, &n.listFolded, func() { if g.StageAll != nil { a.stageWorkspace(p, *g.StageAll) } }) + if n.listFolded { + return + } for _, group := range g.Groups { a.drawRepositoryGroup(c, p, group) } @@ -45,9 +44,10 @@ func (a *App) drawRepositoryChanges(c ui.C, p *project) { } // drawRepositoryGroup declares the group of one repository of the change list: its fold, its -// checkbox, its color, name and count, its commit button, and then its changes unless it is folded. -// A nested repository's changes are read-only apart from staging; the project's own are the ones the -// Commit tool window's rows act on. +// checkbox, its color, name and count, the branch its repository has checked out, and then its +// changes unless it is folded. The Commit button commits every repository with staged changes, as +// IDEA's does, so a group has no button of its own. A nested repository's changes are read-only +// apart from staging; the project's own are the ones the Commit tool window's rows act on. func (a *App) drawRepositoryGroup(c ui.C, p *project, group core.WorkspaceChangeGroup) { t := a.text.Commit lang := a.language() @@ -62,12 +62,11 @@ func (a *App) drawRepositoryGroup(c ui.C, p *project, group core.WorkspaceChange color = a.colors.Accent } folded := p.nested.folded[id] - ui.Row(rc).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).Gap(repositoryGroupGap).PadX(8).Children(func() { - chevron, foldLabel := icons.ChevronDown, i18n.Shared(lang, "desktop.nested.collapse") - if folded { - chevron, foldLabel = icons.ChevronRight, i18n.Shared(lang, "desktop.nested.expand") - } - if a.gitIconButton(rc, foldLabel, chevron, false, false) { + indent := a.repositoryChangeIndent() + // The group is one level under the line of the change list: its fold under the list's + // checkbox, its checkbox under the list's title. + ui.Row(rc).Height(logItemHeight).FillWidth().Shrink(0).Items(ui.Center).PadSides(0, 8, 0, 8+a.changeTreeLevel()).Children(func() { + if a.drawChangeTreeFold(rc, folded, i18n.Shared(lang, "desktop.nested.collapse"), i18n.Shared(lang, "desktop.nested.expand")) { rc.After(func() { if p.nested.folded == nil { p.nested.folded = map[string]bool{} @@ -75,39 +74,31 @@ func (a *App) drawRepositoryGroup(c ui.C, p *project, group core.WorkspaceChange p.nested.folded[id] = !folded }) } - if ui.Checkbox(rc, &all, "").Label(group.Name).Disabled(busy || group.Staging == nil).Clicked() && group.Staging != nil { - plan := *group.Staging - rc.After(func() { a.applyStaging(p, id, plan) }) - } - a.drawRepositorySwatch(rc, p, id) - ui.Text(rc, group.Name).Color(color).Weight(gfx.WeightMedium).Ellipsis().Shrink(1) - ui.Text(rc, t.Files(group.FileCount)).Muted().Shrink(0) - if own { - if ui.Button(rc, i18n.Shared(lang, "desktop.nested.commit")).Outline().Disabled(!p.canCommit()).Clicked() { - rc.After(func() { a.startCommitIn(p, p.projectCommit(), false, surfaceButton) }) + ui.Row(rc).Grow(1).Shrink(1).Items(ui.Center).Gap(changeTreeGap).Children(func() { + if a.treeCheckbox(rc, &all, group.Name).Disabled(busy || group.Staging == nil).Clicked() && group.Staging != nil { + plan := *group.Staging + rc.After(func() { a.applyStaging(p, id, plan) }) } - return - } - repo, ok := p.nested.repo(id) - if ui.Button(rc, i18n.Shared(lang, "desktop.nested.commit")).Outline().Disabled(!ok || !p.canCommitNested(*repo)).Clicked() && ok { - target := a.nestedCommitTarget(p, *repo) - rc.After(func() { a.startCommitIn(p, target, false, surfaceButton) }) - } + a.drawRepositorySwatch(rc, p, id) + ui.Text(rc, group.Name).Color(color).Weight(gfx.WeightMedium).Ellipsis().Shrink(1) + ui.Text(rc, t.Files(group.FileCount)).Muted().Shrink(0) + a.drawRepositoryBranch(rc, p, id) + }) }) if folded { return } if group.ParentReference == core.ParentReferenceUnchanged { ui.Paragraph(rc, i18n.Shared(lang, "desktop.nested.refUnchanged"), 2).FontSize(a.theme.Metrics.FontSizeS).Color(a.colors.Subtle). - PadSides(0, 8, 0, repositoryChangeIndent) + PadSides(0, 8, 0, indent) } repo, _ := p.nested.repo(id) for _, change := range changes { if own { - a.drawCommitChange(rc, p, change, repositoryChangeIndent) + a.drawCommitChange(rc, p, change, indent) continue } - toggled, _, _, _ := a.drawChangeRow(rc, change, busy, false, repositoryChangeIndent, func(ui.C) func(*ui.MenuItems) { + toggled, _, _, _ := a.drawChangeRow(rc, change, busy, false, indent, func(ui.C) func(*ui.MenuItems) { return func(*ui.MenuItems) {} }) if toggled && repo != nil { @@ -116,3 +107,21 @@ func (a *App) drawRepositoryGroup(c ui.C, p *project, group core.WorkspaceChange } } } + +// drawRepositoryBranch declares the tag of the branch the repository of a group has checked out, +// the way IDEA's change tree names it after the group's count; there is none until its status is +// read. +func (a *App) drawRepositoryBranch(c ui.C, p *project, id string) { + branch := p.branchOf(id) + switch branch { + case "": + return + case "detached": + branch = i18n.Shared(a.language(), "git.detachedHead") + } + ui.Row(c.Part("branch")).Height(logRefChipHeight).Shrink(1).Items(ui.Center).Gap(logRefChipGap).PadX(logRefChipPad). + Radius(a.theme.Metrics.RadiusItem()).Background(a.colors.Hover).Children(func() { + ui.Icon(c, icons.GitBranch).Size(logRefIconSize, logRefIconSize).Color(a.colors.Subtle) + ui.Text(c, branch).FontSize(a.theme.Metrics.FontSizeS).Ellipsis() + }) +} diff --git a/desktop/internal/workbench/settings.go b/desktop/internal/workbench/settings.go index 2b15e42118..a6e75b4f8f 100644 --- a/desktop/internal/workbench/settings.go +++ b/desktop/internal/workbench/settings.go @@ -187,6 +187,9 @@ func (a *App) newSettingsWindow() *settingswindow.Controller { SetHideParentReferences: func(value bool) { a.post(func(a *App) { a.setHideParentReferences(value) }) }, + SetGitLogLimits: func(single, merged int) { + a.post(func(a *App) { a.setGitLogLimits(single, merged) }) + }, SetGitConsole: func(value core.GitConsolePreferences) { a.post(func(a *App) { a.setGitConsolePreferences(value) }) }, @@ -421,6 +424,7 @@ func (a *App) openSettingsPageWith(surface actionSurface, page settingsPage, que HideProjectColors: a.settings.HideProjectColors, ProjectOpenDestination: a.settings.ProjectOpenDestination, HideGitGutter: a.settings.HideGitGutter, InlineGitBlame: a.settings.InlineGitBlame, HideChangeLists: a.settings.HideChangeLists, HideParentReferences: a.settings.HideParentReferences, + GitLogLimit: a.gitLogLimit(), GitLogMergedLimit: a.gitLogMergedLimit(), GitConsole: a.settings.GitConsole, DisableSemanticHighlight: a.settings.DisableSemanticHighlight, VimMode: a.settings.VimMode, diff --git a/desktop/internal/workbench/workspace_repositories_visual_test.go b/desktop/internal/workbench/workspace_repositories_visual_test.go index efac507c9c..2f5331613e 100644 --- a/desktop/internal/workbench/workspace_repositories_visual_test.go +++ b/desktop/internal/workbench/workspace_repositories_visual_test.go @@ -16,8 +16,10 @@ import ( // TestVisualWorkspaceRepositories captures the views of a folder that is no repository itself and // holds three: the branch popup listing them with one's panel open beside its row, the Git log -// with the color strip of the repository it walks, the Paths filter's Roots, and the Commit -// window's groups. +// with the color strip of the repository it walks and each repository's own sections in the +// reference pane, the Paths filter's Roots, the repository list behind the name after the filter +// chips, the log of two repositories merged by date, the Commit window's groups, and the Push +// Commits dialog Commit and Push opens on the three repositories. func TestVisualWorkspaceRepositories(t *testing.T) { out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") if out == "" { @@ -27,17 +29,30 @@ func TestVisualWorkspaceRepositories(t *testing.T) { t.Fatal(err) } for _, look := range []struct{ theme, language string }{{"dark", "zh-Hans"}, {"light", "en"}} { - for _, scene := range []string{"branch-popup", "git-log", "log-roots", "log-more", "commit-groups"} { + for _, scene := range []string{"branch-popup", "git-log", "log-roots", "log-choose", "log-merged", "log-more", "commit-groups", "push-commits"} { t.Run(scene+"-"+look.theme, func(t *testing.T) { + // Fixed dates, so the merged log interleaves the two repositories the same way + // on every run. + at := func(date string) { + t.Setenv("GIT_AUTHOR_DATE", date) + t.Setenv("GIT_COMMITTER_DATE", date) + } + at("2026-11-09T09:00:00") parent := newWorkspaceFolder(t, "backend", "frontend", "shared") frontend, backend := filepath.Join(parent, "frontend"), filepath.Join(parent, "backend") - for _, message := range []string{"Add the sign-in form", "Validate the email field", "Show the session banner"} { - gitRun(t, backend, "commit", "--allow-empty", "-m", message) + commit := func(dir, message, date string) { + at(date) + gitRun(t, dir, "commit", "--allow-empty", "-m", message) } + commit(backend, "Add the sign-in form", "2026-11-10T09:30:00") + commit(backend, "Validate the email field", "2026-11-11T10:15:00") + commit(backend, "Show the session banner", "2026-11-12T16:40:00") gitRun(t, backend, "branch", "feature/login") gitRun(t, backend, "branch", "release/1.0") gitRun(t, frontend, "branch", "feature/theme") gitRun(t, frontend, "switch", "-c", "develop") + commit(frontend, "Lay out the dashboard", "2026-11-10T14:00:00") + commit(frontend, "Tune the dark palette", "2026-11-12T11:20:00") prefs := store.At(t.TempDir()) if err := prefs.Save(settingsFile, settings{Theme: themeChoice(look.theme), Language: look.language, DisableAutoSave: true}); err != nil { t.Fatal(err) @@ -58,7 +73,7 @@ func TestVisualWorkspaceRepositories(t *testing.T) { h.click(center(h.hitLabeled(h.app.text.Title.BranchMenu))) label := i18n.SharedFormat(h.app.language(), "desktop.branch.repositoryPanel", map[string]string{"repository": "frontend", "branch": "develop"}) h.click(center(h.popupHit(label))) - case "git-log", "log-roots", "log-more": + case "git-log", "log-roots", "log-choose", "log-merged", "log-more": h.app.layout.gitTab = gitTabLog if !h.app.chrome.isOpen(catalogIndex[itemGit]) { h.click(center(h.button(itemGit))) @@ -69,11 +84,57 @@ func TestVisualWorkspaceRepositories(t *testing.T) { switch scene { case "log-roots": h.click(center(h.hitLabeled(h.app.text.Git.FilterPaths))) + case "log-choose": + h.click(center(h.hitLabeled(h.app.text.Git.Repositories.Choose))) + case "log-merged": + choose := h.app.text.Git.Repositories.Choose + h.click(center(h.hitLabeled(choose))) + label := i18n.SharedFormat(h.app.language(), "desktop.nested.rootToggle", map[string]string{"name": "frontend"}) + h.click(center(h.hitLabeled(label))) + h.settleUntil("backend's and frontend's histories in one list", func() bool { + return p.walksSeveral() && !p.log.loading && len(p.log.graph.Rows) == 7 + }) + h.click(center(h.hitLabeled(choose))) + if p.log.popover != logPopoverNone { + t.Fatalf("popover %v after clicking the repository name again", p.log.popover) + } + h.relayLogBar() case "log-more": h.click(center(h.hitLabeled(i18n.Shared(h.app.language(), "git.log.toolbar.moreActions")))) } case "commit-groups": h.click(center(h.button(itemCommit))) + case "push-commits": + // backend's remote lacks its last commits, frontend publishes a new branch, + // and shared has no remote. + remotes := t.TempDir() + for _, name := range []string{"backend", "frontend"} { + gitRun(t, remotes, "init", "--bare", filepath.Join(remotes, name+".git")) + gitRun(t, filepath.Join(parent, name), "remote", "add", "origin", filepath.Join(remotes, name+".git")) + } + at("2026-11-13T09:10:00") + if err := os.MkdirAll(filepath.Join(backend, "api"), 0o755); err != nil { + t.Fatal(err) + } + for _, name := range []string{"session.go", "session_test.go", "routes.go"} { + if err := os.WriteFile(filepath.Join(backend, "api", name), []byte("package api\n"), 0o600); err != nil { + t.Fatal(err) + } + } + gitRun(t, backend, "add", "api") + gitRun(t, backend, "commit", "-m", "Wire the session API") + gitRun(t, backend, "push", "-q", "origin", "HEAD~3:refs/heads/main") + gitRun(t, backend, "fetch", "-q", "origin") + gitRun(t, backend, "branch", "-q", "--set-upstream-to", "origin/main", "main") + gitRun(t, frontend, "push", "-q", "origin", "main") + bindings := []core.WorkspaceCommitRepository{ + {ID: "backend", Root: backend}, {ID: "frontend", Root: frontend}, {ID: "shared", Root: filepath.Join(parent, "shared")}, + } + h.app.openWorkspacePush(p, bindings, nil, nil, surfaceButton) + s := &p.review.workspacePush + h.settleUntil("the push review and the selected commit's files", func() bool { + return s.reviewed && !s.loading && s.fileState == logFilesReady + }) } h.settleChain() if err := session.Screenshot(filepath.Join(out, "workspace-"+scene+"-"+look.theme+".png")); err != nil { diff --git a/docs/assets/workspace-repositories/README.md b/docs/assets/workspace-repositories/README.md index 52790519a9..ad9974d5fa 100644 --- a/docs/assets/workspace-repositories/README.md +++ b/docs/assets/workspace-repositories/README.md @@ -1,16 +1,19 @@ # 多仓库项目文件夹测试截图 来自生产 Viva Page 的无头渲染。项目文件夹本身不是 Git 仓库,里面有三个独立仓库 backend、frontend、shared, -由测试在临时目录中创建;颜色由 Core 按仓库分配。深色使用中文、浅色使用英文。截图不代表 macOS/Windows -原生窗口验收。 +由测试在临时目录中创建;颜色由 Core 按仓库分配。提交日期固定,混排顺序每次相同。深色使用中文、浅色使用英文。 +截图不代表 macOS/Windows 原生窗口验收。 | 场景 | 深色中文 | 浅色英文 | | --- | --- | --- | | 标题栏分支入口:先列出“提交…”,再按 IDEA 的样式逐行列出仓库,每行有颜色方块、仓库名、右侧的当前分支和 ›;点击 frontend 后,面板在这一行旁边展开,列出该仓库的分支操作和“frontend 中的最近分支 / 本地分支 / 远程分支 / 标签”,在面板里新建、检出等操作只作用于 frontend | [截图](workspace-branch-popup-dark.png) | [截图](workspace-branch-popup-light.png) | -| Git 日志:文件夹本身不是仓库,Core 选第一个嵌套仓库 backend;提交行最左侧是 backend 的颜色条,筛选栏在“路径”之后用仓库颜色写明正在查看的仓库,左侧引用面板里其他仓库按各自颜色分组 | [截图](workspace-git-log-dark.png) | [截图](workspace-git-log-light.png) | -| 路径筛选器下方的“仓库根目录”:按颜色列出三个仓库并勾选正在查看的一个,点击即切换日志查看的仓库 | [截图](workspace-log-roots-dark.png) | [截图](workspace-log-roots-light.png) | +| Git 日志:文件夹本身不是仓库,Core 选第一个嵌套仓库 backend;提交行最左侧是 backend 的颜色条;筛选栏“路径”之后是仓库名,用仓库颜色显示,带下拉箭头,点击可选择仓库;左侧引用面板每个仓库一个节点,节点下各有自己的“本地 / 远程 / 标签” | [截图](workspace-git-log-dark.png) | [截图](workspace-git-log-light.png) | +| 路径筛选器下方的“仓库根目录”:按颜色列出三个仓库并勾选正在查看的一个;勾选或取消勾选即改变日志查看的仓库 | [截图](workspace-log-roots-dark.png) | [截图](workspace-log-roots-light.png) | +| 点击筛选栏里的仓库名:弹出同一份仓库列表,可多选 | [截图](workspace-log-choose-dark.png) | [截图](workspace-log-choose-light.png) | +| 勾选 backend 和 frontend:Core 把两个仓库的历史按提交时间混排成一个列表,各仓库内部保持 Git 顺序;每行左侧是所属仓库的颜色条,两个仓库的图互不相连;筛选栏的仓库名变成两个颜色方块和“2 个仓库” | [截图](workspace-log-merged-dark.png) | [截图](workspace-log-merged-light.png) | | Git 日志筛选栏放不下全部视图按钮时:筛选项和仓库名完整保留,放不下的按钮收进末尾的“更多操作”(…)菜单,每项带图标,“显示提交详情”等开关项开启时打勾;全部收进菜单后文本筛选框再缩窄,最后才裁掉筛选项 | [截图](workspace-log-more-dark.png) | [截图](workspace-log-more-light.png) | -| 提交窗口:按仓库分组,每组有暂存复选框、颜色、文件数和“提交此仓库”;顶部复选框按 Core 的计划暂存全部仓库;状态栏统计所有仓库的更改数 | [截图](workspace-commit-groups-dark.png) | [截图](workspace-commit-groups-light.png) | +| 提交窗口:按仓库分组,每组有暂存复选框、颜色、文件数和该仓库当前分支的标签,组内没有单独的提交按钮;顶部复选框按 Core 的计划暂存全部仓库;状态栏统计所有仓库的更改数 | [截图](workspace-commit-groups-dark.png) | [截图](workspace-commit-groups-light.png) | +| “提交并推送”提交完成后打开的“推送提交”对话框:左侧每个仓库一行,有勾选框、仓库名和“分支 → origin : 分支”,下面列出待推送的提交;backend 的远程缺最后几次提交,frontend 推送时新建远程分支,shared 没有远程,显示“定义远程”且不能勾选;右侧是选中提交的变更文件;底部是“推送标记(T)”和“当前分支 / 所有”;推送按 Core 的顺序进行,子模块先于记录它的父仓库 | [截图](workspace-push-commits-dark.png) | [截图](workspace-push-commits-light.png) | 复验:设置 `LITHE_VISUAL_OUTPUT_DIR`,通过 `scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualWorkspaceRepositories$' diff --git a/docs/assets/workspace-repositories/workspace-branch-popup-dark.png b/docs/assets/workspace-repositories/workspace-branch-popup-dark.png index 95fc71a469..6c8e5f8e7c 100644 Binary files a/docs/assets/workspace-repositories/workspace-branch-popup-dark.png and b/docs/assets/workspace-repositories/workspace-branch-popup-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-commit-groups-dark.png b/docs/assets/workspace-repositories/workspace-commit-groups-dark.png index e8aa1bbec3..e17aeb05a1 100644 Binary files a/docs/assets/workspace-repositories/workspace-commit-groups-dark.png and b/docs/assets/workspace-repositories/workspace-commit-groups-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-commit-groups-light.png b/docs/assets/workspace-repositories/workspace-commit-groups-light.png index 5454f1ffc6..f55b1f3c74 100644 Binary files a/docs/assets/workspace-repositories/workspace-commit-groups-light.png and b/docs/assets/workspace-repositories/workspace-commit-groups-light.png differ diff --git a/docs/assets/workspace-repositories/workspace-git-log-dark.png b/docs/assets/workspace-repositories/workspace-git-log-dark.png index 0e2e8a1c9d..4de7e321ea 100644 Binary files a/docs/assets/workspace-repositories/workspace-git-log-dark.png and b/docs/assets/workspace-repositories/workspace-git-log-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-git-log-light.png b/docs/assets/workspace-repositories/workspace-git-log-light.png index d491042c33..0874df77eb 100644 Binary files a/docs/assets/workspace-repositories/workspace-git-log-light.png and b/docs/assets/workspace-repositories/workspace-git-log-light.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-choose-dark.png b/docs/assets/workspace-repositories/workspace-log-choose-dark.png new file mode 100644 index 0000000000..41550b2893 Binary files /dev/null and b/docs/assets/workspace-repositories/workspace-log-choose-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-choose-light.png b/docs/assets/workspace-repositories/workspace-log-choose-light.png new file mode 100644 index 0000000000..62c8097b67 Binary files /dev/null and b/docs/assets/workspace-repositories/workspace-log-choose-light.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-merged-dark.png b/docs/assets/workspace-repositories/workspace-log-merged-dark.png new file mode 100644 index 0000000000..4c25b5eb8f Binary files /dev/null and b/docs/assets/workspace-repositories/workspace-log-merged-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-merged-light.png b/docs/assets/workspace-repositories/workspace-log-merged-light.png new file mode 100644 index 0000000000..38476c12dc Binary files /dev/null and b/docs/assets/workspace-repositories/workspace-log-merged-light.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-more-dark.png b/docs/assets/workspace-repositories/workspace-log-more-dark.png index 1a8512ea21..b4d91904f6 100644 Binary files a/docs/assets/workspace-repositories/workspace-log-more-dark.png and b/docs/assets/workspace-repositories/workspace-log-more-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-more-light.png b/docs/assets/workspace-repositories/workspace-log-more-light.png index 893bd5321b..6fce5a5898 100644 Binary files a/docs/assets/workspace-repositories/workspace-log-more-light.png and b/docs/assets/workspace-repositories/workspace-log-more-light.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-roots-dark.png b/docs/assets/workspace-repositories/workspace-log-roots-dark.png index d8c4244048..8b9d025f87 100644 Binary files a/docs/assets/workspace-repositories/workspace-log-roots-dark.png and b/docs/assets/workspace-repositories/workspace-log-roots-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-log-roots-light.png b/docs/assets/workspace-repositories/workspace-log-roots-light.png index 87d60991e3..cf0253c315 100644 Binary files a/docs/assets/workspace-repositories/workspace-log-roots-light.png and b/docs/assets/workspace-repositories/workspace-log-roots-light.png differ diff --git a/docs/assets/workspace-repositories/workspace-push-commits-dark.png b/docs/assets/workspace-repositories/workspace-push-commits-dark.png new file mode 100644 index 0000000000..659e6c681c Binary files /dev/null and b/docs/assets/workspace-repositories/workspace-push-commits-dark.png differ diff --git a/docs/assets/workspace-repositories/workspace-push-commits-light.png b/docs/assets/workspace-repositories/workspace-push-commits-light.png new file mode 100644 index 0000000000..34acf5b5f6 Binary files /dev/null and b/docs/assets/workspace-repositories/workspace-push-commits-light.png differ diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index d59ac799af..a9f76ccfdb 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -31,14 +31,18 @@ native_path() { # .worktrees, .DS_Store and .lithe by itself; workspace.configureVisibility takes the # manifests of the enabled plugins and hides the folders their build systems name in # layout.hiddenDirectoryNames and their VCS providers name as directory markers, in every -# workspace, until the next call replaces them (#1856). On top of #74 squash-merged, which -# adds git.workspacePushPreview, the multi-repository push preview ordering submodules before -# their parents, which the desktop does not send yet; #69 squash-merged, so Core knows no -# runtime by name and go and node resolve through their tool definitions like any other -# runtime without executables, with no hostManaged field (#1856); and #71 squash-merged, which -# adds git.workspaceHistoryMerge, the optional chosen of git.workspaceRepositorySelection and -# the optional maxCommits and limitReached of git.historyPage, none of which the desktop sends -# or reads yet (#2013). +# workspace, until the next call replaces them (#1856). On top of #74 squash-merged: +# git.workspacePushPreview reads for each workspace repository whether it can push (ready, up to +# date, no remote, empty, detached HEAD or failed), its push preview and target, and the order to +# push them in, a submodule before the repository that records it, which the desktop's Push +# Commits dialog reads (#2013); #69 squash-merged, so Core knows no runtime by name and go and +# node resolve through their tool definitions like any other runtime without executables, with no +# hostManaged field (#1856); and #71 squash-merged: git.workspaceHistoryMerge interleaves the +# loaded history pages of several workspace repositories newest first, each in Git's own order, +# stops where a repository with pages left runs out and names it pending, and keys a hash several +# repositories hold @; git.historyPage takes maxCommits and answers limitReached; +# git.workspaceRepositorySelection takes chosen, the set a view walks together, and answers the +# picks still listed in discovery order; the desktop's Git Log sends and reads all of them (#2013). # Lithe-core-rust main at 5a8d786, #67 squash-merged: toolchains.candidates takes the optional # commandHomes, lists the commands found on the PATH as shell rows, and offers each shell home that # checks out as an installations entry with provider host:shell, once per canonical home (#2032). diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index 1a1c1bfd9e..c6f415d0a3 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -1058,6 +1058,28 @@ "desktop.git.last30Days": "Last 30 Days", "desktop.git.last7Days": "Last 7 Days", "desktop.git.loadMoreFailed": "Could not load older commits. Refresh history", + "desktop.git.log.limitReached": "Read {count} commits; older commits are beyond the read limit", + "desktop.git.log.adjustLimit": "Adjust Limit…", + "desktop.git.pushAll.title": "Push Commits", + "desktop.git.pushAll.description": "Check the repositories to push, review destinations and commits, then push.", + "desktop.git.pushAll.defineRemote": "Define remote", + "desktop.git.pushAll.emptyRepository": "Empty repository", + "desktop.git.pushAll.detachedHead": "Detached HEAD", + "desktop.git.pushAll.upToDate": "Up to date", + "desktop.git.pushAll.readFailed": "Cannot read: {reason}", + "desktop.git.pushAll.pushTags": "Push tags (T)", + "desktop.git.pushAll.tagsCurrentBranch": "Current Branch", + "desktop.git.pushAll.tagsAll": "All", + "desktop.git.pushAll.skipped": "Not pushed: {repository} failed to push", + "desktop.git.pushAll.pushed": "Pushed", + "desktop.git.pushAll.failed": "Push failed: {reason}", + "desktop.git.pushAll.someFailed": "Some repositories were not pushed; see the Push Commits dialog.", + "desktop.git.pushAll.push": "Push (P)", + "desktop.git.pushAll.noCommitSelected": "Select a commit to see its changed files", + "desktop.git.pushAll.loadingFiles": "Loading changed files…", + "desktop.git.pushAll.filesFailed": "Cannot load changed files: {reason}", + "desktop.git.pushAll.noChangedFiles": "This commit has no changed files", + "desktop.git.pushAll.noRepositories": "No repositories to push", "desktop.git.loading": "Loading…", "desktop.git.locateBranch": "Navigate Log to Selected Branch", "desktop.git.log": "Log", @@ -10621,7 +10643,6 @@ "desktop.files.excludeFailed": "Could not exclude the folder: {reason}", "desktop.worktree.openNewWindow": "Open in New Window", "desktop.worktree.openNewWindowFailed": "Could not open the worktree in a new window: {reason}", - "desktop.nested.commit": "Commit Repository", "desktop.nested.refUnchanged": "The parent repository's reference to this submodule is unchanged. Commit here, then update the parent to record it.", "desktop.files.batchDelete": "Delete {count} Items…", "desktop.files.batchDeleteTitle": "Delete Items", @@ -10720,6 +10741,13 @@ "desktop.git.settings.changeListsHelp": "Groups the Commit window's changes by local change list, with the bar that creates, renames and deletes lists. Turned off, every change is listed in one flat list and all staged changes commit together. The lists and their assignments are kept.", "desktop.git.settings.parentReferences": "Show Update Parent Repository References", "desktop.git.settings.parentReferencesHelp": "Shows the option that records the new commits of submodules in their parent repositories. Turned off, the option is hidden and every commit updates the parent references.", + "desktop.git.settings.logLimits": "Git Log", + "desktop.git.settings.logLimitsHelp": "The most commits the Git Log reads. When it reaches the limit, the end of the log says older commits are beyond the read limit; a higher limit loads more slowly and uses more memory.", + "desktop.git.settings.logLimitSingle": "One repository", + "desktop.git.settings.logLimitSingleHelp": "The most commits read while the log shows one repository. The default is 5,000.", + "desktop.git.settings.logLimitMerged": "Several repositories", + "desktop.git.settings.logLimitMergedHelp": "The most commits read in all while the log merges several chosen repositories by date. The default is 20,000.", + "desktop.git.settings.logLimitDefault": "{count} (default)", "desktop.git.settings.console.omitted": "Git Console: Omitted Queries", "desktop.git.settings.console.omittedHelp": "A kind that is on is not written to the Git console and takes none of the records it keeps; turning a kind on also removes the successful queries of it the console already recorded. The commands you run, failed Git requests, the failed queries of the operations you start and unexpected exit codes always show. The reads that refresh automatically as repositories change (status, gutter markers, inline blame and so on) are never recorded. Every switch starts as in IntelliJ IDEA: all omitted.", "desktop.git.settings.console.references": "Omit Background Branch Reads", @@ -10753,8 +10781,12 @@ "desktop.nested.collapse": "Collapse Repository", "desktop.nested.expand": "Expand Repository", "desktop.nested.roots": "Roots", + "desktop.nested.rootsAll": "Select All", + "desktop.nested.rootToggle": "Show {name} in the Log", "desktop.git.repo.current": "Repository: {name}", + "desktop.git.repo.several": "{count} Repositories", "desktop.git.repo.back": "Back to {name}", + "desktop.git.repo.choose": "Choose Repositories", "desktop.pull.menu": "Pull…", "desktop.pull.title": "Pull", "desktop.pull.prompt": "Pull the chosen remote branch into the branch checked out in the repository.", diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index 8778e80ff9..0f6555973b 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -1058,6 +1058,28 @@ "desktop.git.last30Days": "最近 30 天", "desktop.git.last7Days": "最近 7 天", "desktop.git.loadMoreFailed": "无法加载更早的提交。刷新历史", + "desktop.git.log.limitReached": "已读取 {count} 条提交,更早的提交超出可读取范围", + "desktop.git.log.adjustLimit": "调整上限…", + "desktop.git.pushAll.title": "推送提交", + "desktop.git.pushAll.description": "勾选要推送的仓库,确认目标和提交后推送。", + "desktop.git.pushAll.defineRemote": "定义远程", + "desktop.git.pushAll.emptyRepository": "空仓库", + "desktop.git.pushAll.detachedHead": "分离 HEAD", + "desktop.git.pushAll.upToDate": "已是最新", + "desktop.git.pushAll.readFailed": "无法读取:{reason}", + "desktop.git.pushAll.pushTags": "推送标记(T)", + "desktop.git.pushAll.tagsCurrentBranch": "当前分支", + "desktop.git.pushAll.tagsAll": "所有", + "desktop.git.pushAll.skipped": "未推送:{repository} 推送失败", + "desktop.git.pushAll.pushed": "已推送", + "desktop.git.pushAll.failed": "推送失败:{reason}", + "desktop.git.pushAll.someFailed": "有仓库没有推送成功,详情见推送对话框。", + "desktop.git.pushAll.push": "推送(P)", + "desktop.git.pushAll.noCommitSelected": "选择一个提交查看变更文件", + "desktop.git.pushAll.loadingFiles": "正在加载变更文件…", + "desktop.git.pushAll.filesFailed": "无法加载变更文件:{reason}", + "desktop.git.pushAll.noChangedFiles": "此提交没有变更文件", + "desktop.git.pushAll.noRepositories": "没有可推送的仓库", "desktop.git.loading": "正在读取…", "desktop.git.locateBranch": "在日志中定位所选分支", "desktop.git.log": "日志", @@ -10621,7 +10643,6 @@ "desktop.files.excludeFailed": "无法排除该文件夹:{reason}", "desktop.worktree.openNewWindow": "在新窗口中打开", "desktop.worktree.openNewWindowFailed": "无法在新窗口中打开工作树:{reason}", - "desktop.nested.commit": "提交此仓库", "desktop.nested.refUnchanged": "父仓库中该子模块的引用没有变化。在此提交后需要在父仓库中更新引用。", "desktop.files.batchDelete": "删除 {count} 项…", "desktop.files.batchDeleteTitle": "删除项目", @@ -10720,6 +10741,13 @@ "desktop.git.settings.changeListsHelp": "在提交窗口按本地更改列表分组变更,并显示创建、重命名和删除列表的工具栏。关闭后所有变更平铺显示,已暂存的变更可一起提交;列表及其分配会保留。", "desktop.git.settings.parentReferences": "显示更新父仓库引用", "desktop.git.settings.parentReferencesHelp": "显示是否在父仓库中记录子模块新提交的选项。关闭后隐藏该选项,每次提交都会更新父仓库引用。", + "desktop.git.settings.logLimits": "Git 日志", + "desktop.git.settings.logLimitsHelp": "Git 日志最多读取多少条提交。读到上限后,日志末尾会提示更早的提交超出可读取范围;上限越大,加载越慢,占用内存越多。", + "desktop.git.settings.logLimitSingle": "单个仓库", + "desktop.git.settings.logLimitSingleHelp": "只查看一个仓库时最多读取的提交数,默认 5000。", + "desktop.git.settings.logLimitMerged": "多个仓库混排", + "desktop.git.settings.logLimitMergedHelp": "勾选多个仓库按时间混排时,所有仓库合计最多读取的提交数,默认 20000。", + "desktop.git.settings.logLimitDefault": "{count}(默认)", "desktop.git.settings.console.omitted": "Git 控制台:省略的查询", "desktop.git.settings.console.omittedHelp": "打开的类别不写入 Git 控制台,也不占用控制台保留的记录;打开某个类别时,控制台已记录的该类成功查询也一并移除。你执行的命令、失败的 Git 请求、你发起的操作中失败的查询和意外的退出码始终显示。随仓库变化自动刷新的读取(状态、行号区标记、行尾 Blame 等)从不记录。初始状态与 IntelliJ IDEA 一致:全部省略。", "desktop.git.settings.console.references": "省略后台分支读取", @@ -10753,8 +10781,12 @@ "desktop.nested.collapse": "折叠仓库", "desktop.nested.expand": "展开仓库", "desktop.nested.roots": "仓库根目录", + "desktop.nested.rootsAll": "全选", + "desktop.nested.rootToggle": "在日志中显示 {name}", "desktop.git.repo.current": "仓库:{name}", + "desktop.git.repo.several": "{count} 个仓库", "desktop.git.repo.back": "切回 {name}", + "desktop.git.repo.choose": "选择仓库", "desktop.pull.menu": "拉取…", "desktop.pull.title": "拉取", "desktop.pull.prompt": "将所选远程分支拉取并整合到该仓库当前检出的分支。", diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index 13c9ce4e65..ad82ddb291 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -10056,6 +10056,175 @@ "desktop" ] }, + { + "id": "desktop.git.log.limitReached", + "description": "Git Log: the end of a log that read as many commits as its limit while the history goes on", + "platforms": [ + "desktop" + ], + "parameters": { + "count": "integer" + } + }, + { + "id": "desktop.git.log.adjustLimit", + "description": "Git Log: the button at the end of a log that reached its limit and opens the Git Log limits settings", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.title", + "description": "Push Commits dialog: the title", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.description", + "description": "Push Commits dialog: the description read by assistive technology", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.defineRemote", + "description": "Push Commits dialog: shown instead of the destination of a repository without a remote", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.emptyRepository", + "description": "Push Commits dialog: shown for a repository whose branch has no commit yet", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.detachedHead", + "description": "Push Commits dialog: shown for a repository whose HEAD is detached", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.upToDate", + "description": "Push Commits dialog: shown for a branch its remote already has", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.readFailed", + "description": "Push Commits dialog: a repository Git could not read", + "platforms": [ + "desktop" + ], + "parameters": { + "reason": "string" + } + }, + { + "id": "desktop.git.pushAll.pushTags", + "description": "Push Commits dialog: the checkbox that sends tags with the pushes", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.tagsCurrentBranch", + "description": "Push Commits dialog: the tag choice that sends the tags of the pushed branch", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.tagsAll", + "description": "Push Commits dialog: the tag choice that sends every tag", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.skipped", + "description": "Push Commits dialog: a repository not pushed because a submodule it records failed to push", + "platforms": [ + "desktop" + ], + "parameters": { + "repository": "string" + } + }, + { + "id": "desktop.git.pushAll.pushed", + "description": "Push Commits dialog: a repository the last push sent", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.failed", + "description": "Push Commits dialog: a repository whose push failed", + "platforms": [ + "desktop" + ], + "parameters": { + "reason": "string" + } + }, + { + "id": "desktop.git.pushAll.someFailed", + "description": "Push Commits dialog: the notification when some repositories were not pushed", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.push", + "description": "Push Commits dialog: the button that pushes the checked repositories", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.noCommitSelected", + "description": "Push Commits dialog: the file side before a commit is selected", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.loadingFiles", + "description": "Push Commits dialog: the file side while the files of the selected commit load", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.filesFailed", + "description": "Push Commits dialog: the file side when the files of the selected commit failed to load", + "platforms": [ + "desktop" + ], + "parameters": { + "reason": "string" + } + }, + { + "id": "desktop.git.pushAll.noChangedFiles", + "description": "Push Commits dialog: the file side of a commit without changed files", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.pushAll.noRepositories", + "description": "Push Commits dialog: shown when no repository can be listed", + "platforms": [ + "desktop" + ] + }, { "id": "desktop.git.loading", "description": "Desktop Git: Loading", @@ -10170,6 +10339,13 @@ "name": "string" } }, + { + "id": "desktop.git.repo.choose", + "description": "Tooltip of the repository name after the Git Log's filter chips in a folder with several repositories: a click lists the repositories to walk", + "platforms": [ + "desktop" + ] + }, { "id": "desktop.git.repo.current", "description": "Header of the Git log's commit list: the repository the log walks", @@ -10180,6 +10356,16 @@ "name": "string" } }, + { + "id": "desktop.git.repo.several", + "description": "Name after the Git Log's filter chips while the log walks several repositories of the folder together in one list", + "platforms": [ + "desktop" + ], + "parameters": { + "count": "string" + } + }, { "id": "desktop.git.searchUsers", "description": "Desktop Git: SearchUsers", @@ -10243,6 +10429,58 @@ "desktop" ] }, + { + "id": "desktop.git.settings.logLimits", + "description": "Version Control settings: title of the card that sets the most commits the Git Log reads", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.settings.logLimitsHelp", + "description": "Help of the Git Log limits card in the Version Control settings", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.settings.logLimitSingle", + "description": "Git Log limits card: the row that sets the most commits read of one repository", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.settings.logLimitSingleHelp", + "description": "Help of the one-repository row of the Git Log limits card", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.settings.logLimitMerged", + "description": "Git Log limits card: the row that sets the most commits read of several repositories merged by date", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.settings.logLimitMergedHelp", + "description": "Help of the several-repositories row of the Git Log limits card", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.git.settings.logLimitDefault", + "description": "Git Log limits card: a choice of the limit that is the default", + "platforms": [ + "desktop" + ], + "parameters": { + "count": "integer" + } + }, { "id": "desktop.git.settings.console.omitted", "description": "Version Control settings: title of the card that chooses which internal Git queries the Git console leaves out", @@ -12947,13 +13185,6 @@ "desktop" ] }, - { - "id": "desktop.nested.commit", - "description": "Button on a nested repository's group: commit its staged changes with the message of the Commit tool window", - "platforms": [ - "desktop" - ] - }, { "id": "desktop.nested.expand", "description": "Button on a nested repository's header in the Commit window: show its changes again", @@ -12970,11 +13201,28 @@ }, { "id": "desktop.nested.roots", - "description": "Head of the repositories of the project folder in the Git Log's Paths filter; a click picks the one the log walks", + "description": "Head of the repositories of the project folder in the Git Log's Paths filter and repository list; a box adds a repository to the log, a click on a name walks it alone", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.nested.rootsAll", + "description": "Button in the Git Log's repository list: walk every repository of the folder together in one list", "platforms": [ "desktop" ] }, + { + "id": "desktop.nested.rootToggle", + "description": "Accessible label of a repository's box in the Git Log's repository list: add the repository to the log or take it out", + "platforms": [ + "desktop" + ], + "parameters": { + "name": "string" + } + }, { "id": "desktop.newProject.advanced", "description": "Desktop new project: advanced", @@ -27158,6 +27406,7 @@ "id": "git.log.collapse", "description": "Windows UI: git.log.collapse", "platforms": [ + "desktop", "windows" ], "parameters": { @@ -27386,6 +27635,7 @@ "id": "git.log.expand", "description": "Windows UI: git.log.expand", "platforms": [ + "desktop", "windows" ], "parameters": { diff --git a/shared/platform-feature-matrix/features/git-history.json b/shared/platform-feature-matrix/features/git-history.json index f82b21202d..2f8ac18e6c 100644 --- a/shared/platform-feature-matrix/features/git-history.json +++ b/shared/platform-feature-matrix/features/git-history.json @@ -21,7 +21,11 @@ "desktop/internal/workbench/git_history_test.go", "desktop/internal/workbench/gitconsole_settings.go", "desktop/internal/settingswindow/git_console_view.go", - "desktop/internal/settingswindow/version_control_view.go" + "desktop/internal/settingswindow/version_control_view.go", + "desktop/internal/workbench/gitlog_limits.go", + "desktop/internal/workbench/gitlog_limits_test.go", + "desktop/internal/settingswindow/git_log_limits_view.go", + "desktop/internal/settingswindow/git_log_limits_view_test.go" ] }, "windows": { @@ -42,12 +46,16 @@ "desktop/internal/workbench/git_history_test.go", "desktop/internal/workbench/gitconsole_settings.go", "desktop/internal/settingswindow/git_console_view.go", - "desktop/internal/settingswindow/version_control_view.go" + "desktop/internal/settingswindow/version_control_view.go", + "desktop/internal/workbench/gitlog_limits.go", + "desktop/internal/workbench/gitlog_limits_test.go", + "desktop/internal/settingswindow/git_log_limits_view.go", + "desktop/internal/settingswindow/git_log_limits_view_test.go" ] }, "owner": "Git", - "verification": "双端多仓库打开 Git Log:隐藏中间工作树后其余仓库颜色保持,切换工作区不得显示旧颜色;共享 Core fixture、跨页桥接和异步界面测试覆盖,完整原生界面及滚动性能验收 pending。 提交历史由 Core 保留作者时区及绝对时间,macOS 与 Windows 日期展示使用该时间;macOS 日期范围通过 Core 按绝对边界比较,系统日历计算夏令时边界。真实 Git、跨时区、重复小时、23/25 小时日及原生缓存回归覆盖;完整双平台界面人工验收仍 pending。 Windows cherry-pick 资格根据当前 HEAD 标识判断,不能把筛选结果第一行当作 HEAD;真实菜单回归覆盖其他分支首行可操作和非首行 HEAD 禁用。分页浏览提交历史、分支图谱和提交详情,确认日期、作者和文件列表一致;macOS Git Log 工具窗口标签悬停有反馈,点击窗口内外时选中标签背景在活动色与非活动色之间切换,标签文字保持相同颜色与常规字重,按下时不变暗;分支最新提交的图谱连线从提交圆点开始,不超出到圆点上方;在双端使用同一包含本地分支、远端引用、标签和合并提交的仓库,核对永久图布局、图头引用排序、合并边投影及跨越 30 行的紧凑长边;在本地分支新增提交后确认分支颜色保持稳定,且不会因共用屏幕泳道直接沿用父分支颜色。双端使用 Community 完整颜色 ID 及明暗主题 RGB 规则;macOS Git Log 不再显示单独的 Fetch/Compare/Checkout/Cherry-pick 横向操作栏,分支树与竖向工具栏分离;检查 Fetch、分支比较、分支右键 Checkout、提交右键 Cherry-pick 和 Fetch 设置仍可用,分支搜索可筛选嵌套路径,并隐藏无匹配项的分组、显示无结果提示;定位按钮滚动到当前所选分支的首个可见提交而不重新加载历史;Git Log 的分支和提交搜索框复用 全局唯一的 LitheSearchFieldStyle,对照 IDEA SearchFieldWithExtension,核对 13pt 常规提示文字、Islands 明暗控件底色与边框色、36pt 外框内的 30pt 可见高度、3pt 外层留白、1pt 常态内描边、向外扩 1pt 的 2pt 聚焦描边及 4pt 圆角;图标与文字间距为 2pt,输入框清除按钮复用已有 16pt IDEA SVG 和 20pt 按钮区域,按上游预留清除图标宽度,移除分支搜索框重复外层水平内边距,提交搜索框按 15 列字体度量和 150pt 最小宽度布局,Search 与 Database 搜索输入框使用相同共享样式;竖栏更新按钮采用 IDEA ExpUI 的明暗 update 图标,按钮与侧边栏图标悬停使用共用工具提示样式,提示的明暗背景、文字色、1pt 内描边、圆角及内边距对齐 IDEA HelpTooltip;隐藏与显示分支使用 IDEA ExpUI 的 chevronLeft/chevronRight 明暗图标;竖栏宽 36pt,展开态按钮为 22pt 且四周保留工具栏内边距,展开态分支树左边框复用与 Commit 标题下边框同源的 1pt 分隔线;收缩态竖栏常态复用展开态侧栏背景,展开与收缩保留提交图谱和详情视图实例、滚动状态及分支宽度,仅切换分支面板与分隔条的占用宽度,按钮占满竖栏,深色 hover 使用 Islands Dark 的 #FFFFFF17,浅色 hover 使用 ExpUI Gray12,不在右侧显示 Show Branches 浮层提示,图标在顶部留 8pt 并使用常规小字号文字;展开后恢复分支树宽度。 使用原生 NSHostingView 渲染验证共享 LitheSearchTextField 的占位文字在深浅主题均为 IDEA Component.infoForeground 对应的 #73767C、13pt 常规字重;空输入框单独绘制占位文字,避免 SwiftUI 原生 prompt 替换其颜色与字重,有内容时占位文字消失并保留原生编辑和主文字色。 Git Log 分支树按 IDEA Community Islands 普通密度核对 24pt 行高、无行间额外间距、13pt 常规文字、12pt 次要计数与 4/12pt 树边距;展开箭头、路径文件夹、普通分支、当前分支和标签使用上游 16pt 明暗 SVG,Local/Remote/Tags 标题不附加图标,当前分支不显示额外蓝色勾选;HEAD 与当前分支是两个互斥选中节点,点击分支、HEAD、清除筛选和切换仓库时核对选中状态;深浅主题核对树行焦点/失焦选中色及 hover,保留多仓库名称、圆点、数量和只读菜单,移除分支行仓库色条;Windows 多仓库分支树的仓库行与 macOS 一致,仓库行使用中性色文件夹图标,并只在图标与名称之间显示 8px 仓库色点,仓库名保持普通文字色,不出现整组着色卡片底色、左侧色条或彩色名称,截断名称通过共享工具提示显示全名,行悬停为箭头光标;确认搜索、分组折叠、右键操作、缓存行比较和滚动状态正常。 Git Log 分支树右侧分隔线与 Commit 标题下边框共用 LitheTheme.toolWindowBorder 和 1pt 厚度,深色为 #26282C、浅色为 #E9EAEE;悬停、拖动开始/移动/结束均保持同色,不高亮,保留原生调整光标、命中区域、拖动尺寸约束及提交宽度行为。 Git Log 中间栏按 IDEA Community FilterComponent、VcsLogGraphTable 和 PaintParameters 核对四个筛选器的 13pt 常规文字、4pt 内边距、16pt 箭头和仅文字悬停反馈;工具栏使用 16pt IDEA 明暗 SVG、22pt 点击区域和共享提示,保留动作及禁用条件;提交列表为 26pt 连续行,图谱尺寸同比缩放,作者与日期同为 13pt 主文字色,日期列按打包字体度量,核对深浅主题行 hover、焦点/失焦选中色及选中覆盖 hover,筛选、分页、箭头命中、上下键导航和右键操作不回归。 分支竖栏设置齿轮复用 LitheIconButtonStyle 的 22pt 点击区域、4pt 圆角和主题 hover/按下背景;点击使用 LitheContextMenuPresenter 的共享操作菜单背景、1pt 边框、行 hover 与键盘导航,保留 Fetch Options 对话框、Show Worktree Repositories 勾选和无工作树时禁用行为,点击外部或按 Esc 关闭菜单。 macOS 下拉菜单仅保留 Project 同源的一套全局共享样式,移除 settingsStyle 切换;Project、Git Log 设置、Terminal、欢迎页及右键子菜单统一使用 8pt 外框圆角、1pt 内描边、24pt 行高、12.5pt 文字、6pt 外留白和 8pt 行内边距,设置选择下拉框共享同一外框与尺寸定义; Git Log 顶部按 IDEA 恢复 Branch: 已选分支名称,保留 Branch 筛选、清除和菜单内勾选;Branch、User、Date、Paths 按 IDEA FilterComponent 保留 4pt 内边距、3pt 箭头间距和 13pt 常规文字,四项文字 hover 为白色且不增加底色。Date 使用共享菜单呈现器,Branch/User 的可搜索列表与分组子菜单使用共享 LitheDropdownRowStyle、24pt 行高和共享菜单外框,Paths 输入面板复用共享菜单外框及搜索输入框样式,保留搜索、选项选中、路径 Apply/Cancel/Clear 和时间范围计算。 Branch/User/Paths 原生弹窗锚点不参与鼠标命中,核对按钮与文字收到 hover/点击、菜单正确弹出且关闭后可再次打开;Date 保持共享菜单呈现器。共享下拉外框裁剪内部内容,明暗主题下 Branch/User 搜索条不能覆盖圆角;Paths 输入框复用共享输入样式并显示正确焦点边框,Clear/Cancel/Apply 复用共享次按钮/主按钮,保留路径应用和清除行为。Branch、User、Paths 的可搜索内容同样使用 LitheContextMenuPresenter 的透明无边框面板,去掉 NSPopover 系统外框,复用 Project 共享背景、1pt 边框和圆角;分组展开与搜索动态调整弹窗尺寸,Esc、点击外部和切换菜单正确关闭。选择分支后清除筛选,确认 Branch 恢复默认标题且关闭按钮消失;关闭按钮保留 16pt closeSmall 明暗 SVG、22pt hover 区域及 4pt 圆角。展开分支树左侧固定线、中间分隔线和右侧详情拖动线均使用 toolWindowBorder 的 1pt 边框,右侧 hover 与拖动不高亮。右侧详情展示图标使用 IDEA previewVertically 明暗 SVG,装饰开关使用 show 眼睛而非 hide 工具窗口减号;所有工具栏展示图标复用 22pt、4pt 圆角的共享 hover 背景,保留原动作与提示。深浅主题渲染核对背景和边框,保留可选图标、勾选、快捷键、禁用、子菜单和键盘导航。 Git Log 提交标题、作者和日期使用 Inter 13 Normal,引用标签 12pt;核对至少 26pt 的字体度量行高、含 leading 的整数基线、长标题与中文/emoji 截断,以及选中合并提交的文字颜色。 所选分支存在时 Log 标签显示 Log: 分支短名(包含 codex/ 路径),选择另一分支立即更新;清除分支筛选后恢复 Log,保留本地化标题、原始分支名和原标签选择/焦点行为。 macOS 标题起点按缩放图谱列距、图文间距和 2pt 文字内边距计算,为对齐参考截图至少预留六列,密集行继续扩宽,不改变图谱节点、连线和箭头命中;在 SwiftUI/AppKit 两条渲染路径核对未选中的合并提交标题、作者、日期统一使用合并灰色,选中后恢复普通文字色,合并判定仅依赖至少两个父节点。 Git Log 右侧文件树使用共享 24pt 行高、19pt 层级缩进、常规字重、文件类型图标和 IDEA FileStatus 文件名颜色,无逐行横线及工具栏重复总数;核对文件夹折叠、文件打开 diff、长名称 hover 展开与横向滚动,拖动宽度不重建行内容。提交详情使用 14pt 外边距、10pt 内间距、等宽 bold 标题、同段作者邮箱时间与引用标签,长内容可滚动;文件树/详情之间分隔线复用共享边框,hover/拖动不高亮。左侧分支树从 180pt 专用下限改为共享 30pt 下限,独立 36pt 竖栏保持原宽,窄树裁剪后可拖回原宽,收缩/展开不重建图谱。 图谱圆点、连线、箭头按 SimpleGraphCellPainter/ PaintUtil 的 FLOOR/ODD 物理像素规则对齐;在 1×/2× 原生位图验证圆点与线宽,在真实 NSHostingView 检查对齐后的上下斜向箭头尖端及内侧描边可导航,切换屏幕只重绘且绘制/命中坐标一致。 时间列复用 Inter 13 常规字体的等宽数字与固定 AM/PM 区域,按应用语言使用英文 12h AM/PM 或中文 24h 格式;核对午夜、正午、未知日期回退、行起点一致及切换语言后的原生日期缓存失效,列表两条渲染路径和提交详情使用相同格式。 连续上下拖动 Git Log,包含上方长 Diff:原生列表只调整可见区域,保持文档身份、滚动位置、Shift/Command 多选、焦点色、键盘与箭头导航、分页和辅助功能;收缩再恢复后列表宽高正确。GitGraphInteractionTests 使用 300 条提交、80 次原生尺寸变化和共享分隔条事件验证,局部新旧路径计时作为诊断,不代替目标工作区帧率验证。 共享分隔容器按已有宽高直接分配两个面板与分隔条的确定矩形,避免 HStack/VStack 最小及理想尺寸探测;splitPaneBounds 覆盖横纵方向、leading/trailing、折叠、子视图身份和有限尺寸,达到尺寸限制后的相同结果不重复写状态。 通过键盘或程序化切换焦点时 Git 标签活动态双向更新;挂载或重新显示 Git Log 不主动抢走编辑器焦点。 在包含展开分支树的 Git Log 中连续拖动外层高度和内部宽度:共享分隔器只在拖动开始/结束传播环境状态,嵌套容器继承祖先状态;拖动期间共享行悬停不更新、提示不登记几何锚点、右键覆盖层暂停,松开后恢复菜单和提示,行内容及滚动状态不重挂载。69 行原生分隔条事件回归检查覆盖层暂停/恢复及内容身份;未悬停控件在平时同样不登记提示锚点。用目标工作区 Time Profiler/Animation Hitches 对照 Terminal 核对持续更新成本及起止开销,split.drag 整次手势时长不能当作单帧延迟;本次仅前端共享交互装饰调整,不修改后端及默认详情高度行为。 中文输入法组词期间,即使绑定文本仍为空,共享 LitheSearchTextField 占位文字立即隐藏;取消组词或删空后恢复,确认中文后仍隐藏。原生 setMarkedText 回归覆盖明暗主题和两个输入框互不影响;保留焦点、键盘提交、搜索/过滤语义及占位字号颜色。原生背景观察视图卸载和移出窗口时清理通知,匹配当前窗口的字段编辑器及所属输入区域,不修改业务绑定。 四个筛选弹窗均以各自按钮左下角为定位锚点,Date 不依赖鼠标点击坐标;空间不足时限制在屏幕可见范围内。原生面板回归核对操作菜单/可搜索内容相同锚点下的左上角、无展开动画和 Esc 关闭回调。共享搜索字段在未聚焦时悬停也显示文本编辑光标,离开或禁用时恢复箭头。 Git Console 左侧六个现有动作使用 Community 原始 16pt 明暗 SVG;22pt 背景、竖向 2/1 按钮留白、5/7 外边距和默认箭头光标。核对查找、软换行、跟随、停止、清空、复制的原有动作与禁用状态,组件资源检查不替代完整应用验收。 按 Community CurrentBranchHighlighter 标出当前本地分支可达的所有父提交,包含合并父节点;深色 #1D2336、浅色 #EDF3FF,选中背景优先,仅已加载图谱可证明的祖先被标记,当前分支/HEAD 单独筛选时不重复染色。引用默认显示并按 GitRefManager/SimpleRefGroup 紧凑合组:本地与上游同提交显示 remote & branch,HEAD/本地/远端/标签使用官方黄/绿/紫/灰轮廓及叠层,标签单独存在时默认只显示图标;长名称按列宽和 22 字符下限缩写,原生可见区 tooltip 保留所有完整名称,滚动后按当前鼠标位置解析。明暗原生渲染检查颜色、宽度、选择优先级及完整名称;GitLogReferenceResizeTests 在真实 GitLogView 中加载 1000 个分支并拖动外层高度,检查可见右键覆盖层数量和挂载生命周期,计时仅作诊断。最新正式预览已进入该工作树,观察全部引用下的深色背景、叠层缩写标签和多次上边缘拖动后的布局恢复;用户随后在本机明确确认“现在不卡顿了”,本次报告的高度拖动卡顿通过用户实机验收;组件计时和混合工作区采样不用于推断唯一根因或量化通用帧延迟,其他主题/悬浮等视觉项继续按各自范围验收。 在 Windows Git Log 选中带多行正文的提交,确认右侧详情在标题下方完整显示正文(保留空行与缩进),复制提交信息和打开提交 Diff 时也包含正文;分支最新提交的图谱连线从提交圆点开始,不超出到圆点上方;在双端使用同一包含本地分支、远端引用、标签和合并提交的仓库,核对永久图布局、图头引用排序、合并边投影及跨越 30 行的紧凑长边;在本地分支新增提交后确认分支颜色保持稳定,且不会因共用屏幕泳道直接沿用父分支颜色。双端使用 Community 完整颜色 ID 及明暗主题 RGB 规则。 读取提交正文期间切换仓库、重新打开另一提交或关闭面板,确认迟到结果不会打开旧 Diff 或覆盖新请求的加载状态。 Windows 另验证:单击提交后编辑区预览该提交第一个文件的 diff;单击或双击 Commit files 中的文件只显示该文件的 diff(不含提交说明,也不显示文件列表),并复用同一个预览标签;Commit files 树中过长的文件或目录名不折叠为省略号,区域随最宽行横向展开,可通过横向滚动条或触控板侧滑左右滑动查看完整名称(与源代码管理变更树一致);Git Log 刚打开、尚未点击提交时不会自动打开 diff;日期列将有 UTC 偏移的提交转换到本机时区后显示相对时间(刚刚、N 分钟前、今天/昨天);英文绝对日期和时间通过 Windows 原生接口遵循系统短日期/时间及用户自定义格式,中文使用中文地区格式,未知偏移仍显示绝对日期;验证美式月/日/年、英式日/月/年、自定义分隔符、12/24 小时制、跨时区相对时间和迟到原生结果保护,真实 WebView2 产品验收为 pending;鼠标移入行时刷新相对时间;作者/日期列可在行内列边缘拖动调整宽度并在重启后保留。 非连续多选提交修改同一路径时,预览保留每个提交的 diff 和提交标识,可通过文件导航分别查看;延迟请求返回前取消选择、隐藏 Git Log、切换仓库或卸载工具窗,确认旧请求不会重新打开或激活预览标签。 Windows 端提交历史仅通过 Git Log 工具窗浏览:源代码管理侧栏入口已更名为 Commit 面板,其 History 标签已移除,面板固定显示变更列表与提交区。命令面板中的 Git: Show History 入口同步移除。 Windows Commit Files 单文件预览使用独立页面:上下箭头导航差异,下箭头在当前文件最后一处后继续进入下一文件并在比较完成后定位第一处差异,整个文件集合末尾禁用且不循环;图片、二进制和无文本差异文件也允许下箭头继续,比较未就绪时禁用以防连续点击跳过文件。左右箭头直接切换当前比较集合的上一文件/下一文件;标签使用 IDEA 的 Repository Diff: 文件名并跟随导航更新,不附加提交 hash。Jump to Source 按最后聚焦侧的补丁位置打开预览所属仓库的文件,重命名使用新路径、删除行映射邻近保留行、已删除文件禁用源跳转;模型更新期间禁用差异动作。保留并排/统一视图、空白显示、Monaco 查找、图片和二进制呈现,普通全量提交比较仍使用多文件页面。真实 WebView2 内核及源文件打开还需目标产品运行验收。 Windows 单文件历史 Diff 外观验证:并排视图使用独立外侧 12px 滚动轨道、8px 滑块和概览,通常的统一视图保留 Monaco 原生 Diff 组件,整文件新增使用真实新行流的独立只读控件,深浅主题检查常态/悬停/拖动色、圆角及边框;实际拖动任一并排滑块后按差异边界同步对应行且模型身份保持。工具栏使用现有 Button,核对 40px 高度和 22px 图标按钮;保留用户字体与字号,默认行距按 14px 字号对应 22px 并随缩放,自定义行距不覆盖。词级高亮开关复用现有 Monaco 装饰能力,关闭只隐藏字符差异、保留整行差异,切换文件保留词级和空白开关。旧/新版本标题显示真实第一父提交、范围基线/目标或非连续提交各自身份,根提交旧侧为空树,重命名显示旧/新路径;短 hash 和截断路径的 tooltip 保留全文。并排标题列宽由独立布局所有者更新 CSS,拖动分隔条时标题跟随且不重建模型;统一视图标题纵向排列。以上浏览器真实组件验证不替代目标 WebView2 产品验收。 Windows 单文件 Diff 滚动条回归:两侧横纵滚动条默认显示,鼠标移到工具栏后仍可见,不依赖悬停;差异概览不绘制重复的宽矩形视口指示,并排由独立外侧轨道负责点击、拖动和滚轮,统一视图保留原生委托。明暗主题、并排/统一视图及长文本双向溢出下检查唯一可见滑块、并排横向同像素偏移同步、纵向对应行同步和模型身份。 历史 Diff 两侧滚动轨道与代码编辑器概览画布背景透明,鼠标不悬停时滑块仍显示;关闭代码编辑器重复概览通道,但保留 Diff 专用差异色条。横向轨道不额外增加内容高度,检查代码能显示在滑块后、底部内容与滚动位置正确,拖动命中保留,并排两侧横向同像素偏移同步、纵向对应行同步。 Windows 并排单文件 Diff 使用两个独立只读 Monaco 代码控件,取消 DiffEditor 的补空白对齐。左右横向滚动按同一像素偏移双向同步,较短侧由 Monaco 钳制到真实内容边界且不反向拉回主动侧;纵向原生代码区、外侧滑块拖动/点击、轨道键盘、滚轮和查找以视口三分之一处为锚点,按 Git 差异块起止边界同步对应行并保留行内偏移,短侧在不等长块内钳制、共同上下文恢复对齐。同步有重入与微小方向保护;双模型替换、布局、字体配置和显式上下导航期间暂停同步。新增旧侧/删除新侧画横跨可见代码区的双像素零行边界,修改区画上下单像素边界;两列行号背景为直边,曲线只在两列之间弯曲,实际偏移改变端点形状。检查文件开头/末尾零行、三态、明暗主题和窄列,代码不补空白、不扩展横向范围;连接面覆盖两列历史行号背景,行号选择和源映射正确。左右外侧各显示透明常显纵向滑块与增删改概览,横向保留原生滚动条,滚动范围截止真实最长代码行。验证深浅主题、折叠展开、Ctrl/Cmd+F 搜索折叠文本、词级开关和预算、统一视图及跨文件首处定位、连续拖动和窄窗口非负尺寸。高频帧二分筛选可见差异,缓存像素边界及概览,不扫描全文、不更新 React;卸载和迟到语言准备清理所有帧、监听、观察器、拖动、两个编辑器和模型。浏览器生产组件验证使用平台记录器,真实 WebView2 产品验收仍为 pending。 外侧轨道预留独立空间,不显示代码;左轨道距面板边缘、右轨道距代码视口各留 4px 间隙,窄列随可用宽度缩减,右侧文字与轨道不重叠;并排和统一预览关闭缩进及括号引导线,保留语法颜色;中央行号缩小边距和曲线间隙,整数布局边界及上下半像素描边消除与代码区的垂直接缝。滚轮在代码、行号和轨道统一加快到两倍,拖动仍映射各侧真实进度,纵向同步对应行;方向键按用户行高移动。有词级结果时修改正文底色按 40% 修改色与 60% 页面背景混合,完整修改色突出替换词的两侧,纯新增和纯删除词分别使用完整增删色,语法前景色和文字透明度保持;关闭词级或超限保留整行底色。验证三态与开头末尾、双向对应行同步、明暗主题、轨道无遮挡、宽窄字体布局和预算回退。 单文件并排及统一视图隐藏补丁 @@ 标题,但保留真正以 @@ 开头的源码、行 ID、源行映射和原始补丁;默认多文件与暂存投影不变。Islands Dark 继承 Darcula 背景,Islands Light 使用 Light 方案,独立差异轨道标记与连接、代码边界共用对应差异背景色。底部保留五个用户实际行高的 padding,模型不增加假行;从任意侧滚到底部验证共同末行对齐与五行留白,字号/行距变化同步更新。 Windows 单文件 Diff 首次打开、左右切文件和同路径新比较均在模型/比较准备完成后定位第一处改动;定位只消费一次,调整词级、空白、字号或主题保持用户当前位置。统一视图的原生 Monaco 增删行、字符与行号栏使用该预览相同的 Islands 背景变量,移除默认字符边框;新增整文件应为深色 #294436 或浅色 #BEE6BE,删除为 #484A4A 或 #D6D6D6,语法前景色不变且其他编辑器主题不被覆盖。 整文件新增采用单流只读代码控件,隐藏不存在的旧侧与连接带,新增背景覆盖行号、代码和底部留白,避免空旧模型的灰色删除行及外圈;新增仅显示新版本、删除仅显示旧版本的一组 hash 与路径。并排两侧及新增单流轨道的增删改标记与对应内容背景共用颜色;原生统一预览关闭 renderIndicators,历史行号旁不显示 +/-。这组新增显示修复按用户要求延后运行验证,提交或 PR 前核对新增文件、普通修改、删除、深浅主题、查找、源跳转与底部留白。 Windows Git Log 单文件和 Commit 文件 Diff 的词级高亮、显示空白符、统一/并排切换均在左侧,最右侧统计当前文件差异,区分无差异/单数/复数;Commit 勾选、部分包含、取消及刷新后 included 数同步变化,全部包含仍显示数量;加载、切换文件及图片/二进制不显示文本差异统计。核对中英文、明暗主题、窄窗口和按钮选中/禁用状态。 Windows 单文件 Diff 上箭头在首处继续进入上一文件最后一处,下箭头在末处进入下一文件首处,集合首尾不循环、加载中禁用;Commit 文件列表随跨文件导航更新选中行并展开祖先、滚动到可见位置,保留编辑器焦点和 include 状态;同文件刷新、历史 Diff、无关仓库和迟到读取不扰动列表。 Windows Git Log 右下角 Commit files 列表同样跟随 Diff 的上一/下一文件导航:选中行移到当前文件,被折叠的父目录自动展开,行滚动到可见位置;预览属于其他提交或范围时不改变选中,点击行不会改变横向滚动。 Windows Git Log 筛选后基于完整已加载历史投影可见祖先:隐藏中间提交以虚线连接,直接父子保持实线,无关分支不误连;合并路径去重并保留永久颜色,未加载父提交经隐藏节点传播,分页补齐后解除缺失标记;清空筛选恢复原图,核对文本、作者、分支名称三种范围、空结果与选择行为。算法和真实表格组件回归通过不代替 WebView2 原生验收,原生验证保持 pending。 Windows 未筛选图与筛选图共用上下半边打印元素:普通浏览的跨行泳道换列必须在共同中点连续连接,合流入边保留各自颜色到提交圆点;核对原始 IDEA 200 条历史输出的列号、方向、终止和颜色身份;截图/原生交互验收仍为 pending,组件输出和 golden 对照不代替 WebView2 验收。 Windows Git Graph 外观:核对明暗主题真实 IDEA RGB、实心节点、直线与筛选虚线、终止箭头及至少六列标题预留;默认 26px 行高,用户字号变化时虚拟行与 SVG 同步扩高;在 100%/125%/150%/200%/300% 缩放及跨屏 DPI 变化下核对奇数物理像素和相邻半边连续性,普通视口调整不重建历史图。箭头能跳到已加载且可见的父/子提交,未加载父节点没有可点击目标;浏览器生产组件验证不代替目标 WebView2 运行验收,原生验证保持 pending。 Windows 历史排序和图导航:在交错分支仓库核对首批/分页/回退及全引用上下文均使用日期顺序,切换分支保持可证明的永久颜色和基础顺序;上下文最多 5000 条,覆盖不完整或哈希重复时保留可见页并回退。核对 upstream/backup 等非 origin 远程引用分类及本地含斜杠分支;背景上下文不阻塞 50 条可见页,分页不取消或重读上下文,切仓库/刷新/卸载取消旧操作且关闭迟到游标。长边开关展开/收起不改变提交、筛选、选择和游标;验证 30/1000 行边界。点击或用 Enter/空格激活上下箭头,选择并滚动到屏幕外端点,挂载后键盘焦点随目标;不误选源行、不误开源行 Diff,保持普通选择/多选/双击/右键和原预览入口。明暗主题及 1x/1.25x/2x 检查箭头尖端与命中范围,真实 WebView2 运行验收保持 pending。 图谱颜色必须跟随 ThemeRegistry 根 data-theme-type 切换;不依赖页面存在 dark class。复用真实 Lithe 明暗主题检查同一已挂载节点与连线的颜色变化、布局不因主题重算,结合主题回归和浏览器真实切换验证。 Windows 分页稳定性:选中顶部提交后向下滚动触发连续分页,确认滚动位置不跳回已选提交,Commit Files 不清空或重读,已选文件及树折叠保持;更新引用、背景上下文和相同 hash 的元数据同样不导航。定位分支头通过独立请求仍能定位已经选中的头提交一次;新选择或切仓库仍读取新文件并丢弃旧结果。组件回归与真实浏览器虚拟列表/IntersectionObserver 验证通过,目标 WebView2 实机验收保持 pending。 Windows Git Log 标题栏不显示固定 Read-only/只读文字,关闭按钮保持靠右,刷新、设置及隐藏操作正常。 Windows Git Log 单个提交右键 New Tag… 输入非空且无空白的标签名,创建指向右键提交完整 hash 的轻量标签并刷新引用和历史;取消不写入,失败保留名称可重试,双击/Enter 不重复创建,多选和写操作期间禁用。仓库或工作区切换关闭旧弹窗,旧请求迟到不得刷新或关闭新弹窗。 Windows 提交区域点击后上下箭头更新可见提交选择和详情,焦点不随虚拟行移除而丢失;筛选、首尾边界、Home/End、Shift 范围选择和 Enter 正常,菜单与输入框保留自己的方向键。 Windows Git Log 鼠标或上下键选择提交后,异步 Diff 自动定位第一处改动但保持提交列表键盘焦点;并排与统一预览均不调用初始 focus。双击/Enter 打开完整 Diff、主动差异跳转及跨文件导航仍进入编辑器。 Windows Git Log 提交右键 New Tag 使用与 Tags 节点同源的 TagIcon(沿用现有标签轮廓图案),核对 16px 图标、菜单对齐和禁用反馈;新补图标的实机视觉确认待完成。 Windows 提交列表菜单键和 Shift+F10 打开当前选中提交的真实菜单;关闭后列表继续上下键导航,菜单操作仍针对所选提交。New Tag 在 tag.gpgSign=true 下生成轻量标签,不运行签名器或消息编辑器,不修改配置。 Windows 提交行高亮和紧凑引用组:在全部引用和其他分支视图核对当前检出分支全父祖先背景,当前分支/HEAD 视图关闭重复高亮;合并提交的说明、作者、日期未选中时弱化、选中后恢复,选中背景优先于分支并区分列表/文件树/窗口焦点。核对明暗主题固定基准色、真实 upstream 合并名称、游离 HEAD、每种最多两个叠加图标、仅标签图标和完整汇总悬停/无障碍提示。宽窄列及字号变化时按至少 22 字符缩略规则布局,只有一个视口尺寸观察器,列拖动不逐行读取宽度,卸载清理;分页不丢滚动/选择,成功后不重读 Commit Files;文件读取失败时 Commit Files 面板显示重试入口,重新选择同一提交或刷新历史也会重试一次,长边导航和新建标签原入口保持。组件与浏览器验证通过,目标 WebView2 实机验收 pending。 Windows Git Log 分支树和提交列表的普通滚轮使用 Community Windows 默认 200ms 和 (0.5,0.505,0.5,1) 曲线;连续同向累积、反向从当前位置重启。核对两处列表的中间帧、Shift 横向滚动、分页保持、顶底边界、键盘定位和滑块拖动取消惯性、关闭工具窗清理帧以及减少动态效果偏好。确定性动画与 DOM 回归通过,真实 WebView2 设备手感验收保持 pending。 Windows graph 标题不再固定预留六列:建议宽度取可见图边数的加权均值与标准差,最多以六列作统一基线,每行按节点与斜边中点扩展,密集行不把其他简单行扩成最大列宽。验证单线/少分支、罕见密集合并、超过六列、筛选、长边开关、引用标签可用宽度及字号/DPI,保持图谱颜色/连线/导航不变。 Windows Git Log 的 Commit Files 文件树沿用 IDEA Windows 默认 200ms 滚轮动画;在文件行、竖向/横向滚动条区域连续滚动、反向及 Shift 横向滚动,确认共用真实视口的动画目标,长文件名保持自然宽度;按下滚动条取消未完成惯性,减少动态效果时直接滚动,切换提交及卸载不残留帧。其它 ScrollArea 默认行为不变。真实 WebView2 交互验收 pending。 Windows Git Log 右键 New Tag 打开弹窗后焦点直接位于标签名输入框,无需点击即可输入,Enter 提交、Esc 关闭。 macOS Git Log 空状态:在非 Git 项目检查明暗主题、窄窗口和键盘操作:13pt 常规文字按 IDEA 左对齐,整组位于内容区上方三分之一处;显示 To track changes to code、GitHub/GitLab 官网链接、Initialize Git repository…、Open Git Settings 和带原始 ContextHelp 图标的 Version control integration(打开 Git 官方文档)。初始化仍先确认,不自动暂存或提交;设置打开既有 Git 设置。未提交仓库、无匹配提交、加载失败及重试保持原动作,所有空状态操作采用文字按钮。 非 Git 项目空状态隐藏 Log/Worktrees/Console 标签、添加按钮、分支树与动作条、筛选/搜索工具栏及提交详情,提示占满工具窗内容区;GitHub、GitLab、初始化、设置及帮助链接悬停仅给当前文字加主题强调色下划线并显示手形,离开后恢复;初始化或切换至真实仓库后恢复原有三栏布局,真实仓库无匹配提交仍保留筛选入口。 空状态字体与间距对照 Community c7f91397:按钮标签显式使用 Inter 13pt Regular;行首破折号按首行基线对齐,21pt 行高加 2pt 间隔,帮助图标间隔 2pt;灰字与链接分别沿 Component.infoForeground 和 Islands Link.activeForeground 核对明暗主题,悬停下划线仍使用当前主题强调色。 macOS 右侧提交详情的分支标签按可见区域懒加载,全部引用仍可滚动查看。重开面板初始化时恢复匹配的提交图和分支树,第一次布局即可读取全部已缓存数据,不依赖出现后的异步任务回填。重开面板复用未变化的分支树,单仓库不重复构建分组副本,多仓库活动根复用已有三类行;引用、仓库、工作树开关、折叠状态改变后拒绝旧树。原生绘制与无障碍日期文本复用缓存,语言改变后刷新。 macOS 大量引用首屏:同提交放置 1,500 个本地分支和 1,500 个远程引用,核对真实 upstream 优先、同名远程自然排序回退、完整提示及每类图标上限;反复切换 Terminal/Git Log,数据版本相同应复用已准备图,改变分支/筛选/图显示选项后不得复用旧图。运行 GitGraphInteractionTests 的 manyReferenceGroups 和 presentationCache;组件耗时仅诊断,整机卡顿以相同数据实测为准。 macOS Git Log 及终端按需创建后由工作台持有实际原生宿主;隐藏再重开及移动停靠位置复用控件。运行 GitLogReferenceResizeTests,验证同一工作台隐藏再重开时,固定原生表面上的提交文档和滚动容器对象身份不变,恢复可见性且尺寸正确,工作台释放后宿主释放;核对语言、主题、搜索、分支操作和终端会话。 Git Log 与终端同时停靠时,从外层横向和纵向分隔条中央及向面板两侧偏移 4pt 处,经窗口发送按下、拖动、松开,确认完整 10pt 命中区仍能提交尺寸、宿主身份保持,面板中央正常交互。;macOS 保留宿主圆角需在明暗主题、侧栏顶部与移动后、项目辉光改变、渐变开关及背景图切换时,与原工作台树四角像素一致(WorkbenchSurfaceBackgroundTests.retainedPaneCornersMatchWorkbenchGradient)。 Windows HEAD 按 Community HeadNodePainter 核对外圈、背景间隔和中心实点:26px 行高、100% 缩放时三层直径为 13/9/5px,125%/150%/200%/300% 按物理像素 FLOOR/ODD 对齐;深浅主题、悬停、当前分支及活动/非活动选择均透出真实行底色,穿过 HEAD 的连线不侵入间隔。普通节点及分叉、筛选、长边展开保持;同边双向终止元素键唯一。目标 WebView2 实机验收保持 pending。 macOS 在明暗主题的窄 Git Log 工具栏中选择长用户名、分支和路径,确认名称与选中值以同一行尾部截断,文字不重叠,清除按钮和重新选择仍可用。 macOS Git Log 接近底部时自动追加较早提交,正常浏览不出现必须点击的加载更多按钮;单一页面最多发起一次边缘请求,追加保留选择和原生视口偏移。无新提交或缺失后续游标时停止并释放游标;失败暂停自动读取,显式刷新重开历史而不重用失败游标。运行 GitGraphInteractionTests.automaticHistoryPaging 与 GitModuleTests.continuousHistoryPagingStopsOnDuplicatePagesAndRefreshesAfterFailure,真实大仓库连续滚动和 Windows WebView2 验收仍 pending。 macOS 深层历史后台刷新:文件状态变化不重开首批,元数据刷新保留已加载窗口和后续页占位,未变结果不重建提交图;外部新提交按可见 hash 与行内偏移保持原生视口,按新行位移补齐旧尾部,保留尾部选择。当前仓库引用只读取一次,多仓库仍独立加载。后台刷新打断自动分页后,即使历史相同也能继续读取新游标;失败仍暂停自动重试。运行 GitModuleTests.backgroundRefreshRetainsDeepHistoryAndSelectionWhileExternalCommitsStillAppear、引用聚合回归及 GitGraphInteractionTests.backgroundHistoryRefreshAnchorsVisibleCommitInsteadOfSelectedCommit/automaticHistoryPaging;真实大仓库长时间滚动仍待用户验收,原生进程 cleanup 超时未独立复现,不将减少重复查询等同于修复所有进程失败。 macOS #1542:显示保留的 Git Log/终端时,横纵分隔条中央及两侧偏移 4pt 仍经窗口事件完成拖动且只提交一次,宿主身份不变;根命中查询深度始终为 1,面板内部连续 100 次查询不产生额外根查询,鼠标移动不回查祖先 SwiftUI。验证禁用、收起(含嵌套分隔条)、恢复、卸载、跨窗口与登记表隔离、实时移动/裁剪、隐藏/透明和弱引用释放;保留宿主内部仍正常命中,外层边缘优先。Diff 两端收起后在普通与保留侧栏下均能经窗口拖回,不触发外层拖动。运行 GitLogReferenceResizeTests、SplitHandleHitTestTests 和 DiffScrollSynchronizationTests;旧实现先出现嵌套命中断言失败,新实现通过。较新 macOS 原生组件回归不替代 macOS 13 Intel 原报告崩溃验收,目标环境验证保持 pending。 历史菜单资格使用 Core 读取真实 HEAD 与第一父链;在筛选/分页、旁支首行、跳选、切换仓库、HEAD 变化和关闭菜单时验证动作状态及迟到结果隔离;两端原生界面验收 pending。 Git 控制台执行日志的记录状态(completed / unconfirmed)、单条与总量保留预算和脱敏由 Core 事件携带,两端不再各自归约或二次脱敏,单条输出预算统一为 32768 字符。 历史刷新的窗口大小、头部新增后保留旧尾部的延伸读取、翻页合并去重与上限、选中提交/焦点/范围锚点的保留统一由 Core `git.historyWindow` 决定;Windows 监听刷新不再把深层历史缩回第一页,选中与锚点在仍已加载时保留,像素级滚动锚点仍留在视图。滚动到深处后触发后台刷新,确认窗口深度、选中行与 Shift 范围起点不变;两端原生界面验收 pending。 Viva 改动文件折叠:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestLogChangedFiles|TestGroupLogFiles' -count=1;实机选择一个改动多个目录的提交,收起与展开文件夹、用方向键和双击操作,切换提交后文件夹重新展开。 Viva 提交详情改动文件横向滚动:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run TestLogChangedFiles -count=1 和 scripts/desktop/desktop-go.sh test ./internal/hscroll -count=1;实机选中路径很长的提交,确认改动文件列表可左右滚动、底部显示细滚动条,暗色主题下删除的文件显示为红色而不是灰色。 Viva 提交详情的哈希、作者、邮箱和日期不截断:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run TestLogCommitDetails -count=1;实机把详情面板拖到最窄,选中作者名和邮箱都很长的提交,确认放不下时换行显示,超长邮箱独占一行并在行内折行,没有省略号。 Viva 控制台:执行提交、推送或工作树清理等写操作后打开 Git 工具窗口的“控制台”页,核对命令、输出、退出码、搜索跳转、折叠、复制和清空;desktop/internal/workbench/gitconsole_test.go 覆盖列表、搜索和清空。 Viva 行标识回归 TestLogCommitKeysKeepFooterInRangeAndSeparate:加载页脚使用独立的合法标识 0,提交从 1 编号,重新排序保留提交标识;升级后的 List/Tree 范围检查不得因分页页脚崩溃。原生三平台长历史分页验收仍 pending。 Git 控制台 TestConsoleRowKeysReserveValidMissingRowIdentity 覆盖列表刷新期间缺失行的保留标识,不与真实行冲突。 Git 控制台开关:运行 scripts/desktop/desktop-go.sh test ./internal/core ./internal/workbench -run 'TestGitConsole|TestConsole' -count=1;实机打开设置 → 版本控制,逐个切换“省略的查询”里的九个开关,确认关闭的类别出现在控制台、打开的类别不再新增记录,执行的命令和失败请求始终显示;切换“显示”里的四个开关,确认查询折叠、无输出提示、临时 -c 配置和仓库名立即按开关重绘,复制全部内容仍带仓库名;重启后开关保持。", - "notes": "Viva 的 Git Log 已有提交列表、分支面板和提交详情,其余能力尚未逐项盘点。提交详情的改动文件按文件夹分组,文件夹先于文件,使用与项目树相同的 desktop/internal/treelist 折叠列表:单击箭头、双击文件夹或方向键展开收起,Enter 打开文件差异;切换提交后所有文件夹重新展开。2026-11-14 起分组由 Core git.changedFileGroups 计算(#1814):目录按段比较、文件按项目树的自然顺序排列(v0.1.4 在 v0.1.12 前),顶层目录为空字符串;Stash 和 Shelf 页同样适用。legacy 是迁移前基线,不代表当前实现。 Viva 提交详情的改动文件列表与项目树共用 desktop/internal/hscroll 横向滚动:列宽取最长一行,滚轮或触控板横向滚动,底部细滚动条显示位置;删除的文件在明暗主题下都用红色(Deleted),不再用暗色下发灰的次要文字色,Commit 工具窗口同样适用。 Git 工具窗口新增“控制台”页:按时间列出 Core 记录的 Git 写操作命令、输出和退出码,支持搜索与上下跳转命中、折叠长输出、复制命令或输出和清空;记录哪些查询和怎么显示由设置 → 版本控制的“Git 控制台:省略的查询”“Git 控制台:显示”两组共 13 个开关决定,初始状态与 IntelliJ IDEA 一致;省略的查询类别成功时在 Core 记录时就丢弃,不占控制台保留的记录,省略一个类别时已记录的该类成功查询一并移除(类别由 gitExecution.consoleQueries 传给 Core,宿主用 queryCategory 标注后台分支读取、Git 操作后重新加载、保存后差异刷新和日志路径筛选,其余由 Core 按命令归类,类别名与 Core fixture 的 queryCategories 对照测试);用户执行的命令、失败的 Git 请求、用户发起的操作中失败的查询、意外退出码和未确认的命令始终显示。显示开关由 git.consolePresentation 的 display 参数在 Core 里生效:成功查询的输出超过 10 行才折叠,可设置为短输出也折叠;删除分支、标签、远程分支、贮藏、工作树等删除类命令的配置、进度和输出从不折叠;复制全部内容仍保留完整命令和仓库。控制台工具栏原“隐藏读取命令”开关改为打开这两组设置的按钮。", + "verification": "双端多仓库打开 Git Log:隐藏中间工作树后其余仓库颜色保持,切换工作区不得显示旧颜色;共享 Core fixture、跨页桥接和异步界面测试覆盖,完整原生界面及滚动性能验收 pending。 提交历史由 Core 保留作者时区及绝对时间,macOS 与 Windows 日期展示使用该时间;macOS 日期范围通过 Core 按绝对边界比较,系统日历计算夏令时边界。真实 Git、跨时区、重复小时、23/25 小时日及原生缓存回归覆盖;完整双平台界面人工验收仍 pending。 Windows cherry-pick 资格根据当前 HEAD 标识判断,不能把筛选结果第一行当作 HEAD;真实菜单回归覆盖其他分支首行可操作和非首行 HEAD 禁用。分页浏览提交历史、分支图谱和提交详情,确认日期、作者和文件列表一致;macOS Git Log 工具窗口标签悬停有反馈,点击窗口内外时选中标签背景在活动色与非活动色之间切换,标签文字保持相同颜色与常规字重,按下时不变暗;分支最新提交的图谱连线从提交圆点开始,不超出到圆点上方;在双端使用同一包含本地分支、远端引用、标签和合并提交的仓库,核对永久图布局、图头引用排序、合并边投影及跨越 30 行的紧凑长边;在本地分支新增提交后确认分支颜色保持稳定,且不会因共用屏幕泳道直接沿用父分支颜色。双端使用 Community 完整颜色 ID 及明暗主题 RGB 规则;macOS Git Log 不再显示单独的 Fetch/Compare/Checkout/Cherry-pick 横向操作栏,分支树与竖向工具栏分离;检查 Fetch、分支比较、分支右键 Checkout、提交右键 Cherry-pick 和 Fetch 设置仍可用,分支搜索可筛选嵌套路径,并隐藏无匹配项的分组、显示无结果提示;定位按钮滚动到当前所选分支的首个可见提交而不重新加载历史;Git Log 的分支和提交搜索框复用 全局唯一的 LitheSearchFieldStyle,对照 IDEA SearchFieldWithExtension,核对 13pt 常规提示文字、Islands 明暗控件底色与边框色、36pt 外框内的 30pt 可见高度、3pt 外层留白、1pt 常态内描边、向外扩 1pt 的 2pt 聚焦描边及 4pt 圆角;图标与文字间距为 2pt,输入框清除按钮复用已有 16pt IDEA SVG 和 20pt 按钮区域,按上游预留清除图标宽度,移除分支搜索框重复外层水平内边距,提交搜索框按 15 列字体度量和 150pt 最小宽度布局,Search 与 Database 搜索输入框使用相同共享样式;竖栏更新按钮采用 IDEA ExpUI 的明暗 update 图标,按钮与侧边栏图标悬停使用共用工具提示样式,提示的明暗背景、文字色、1pt 内描边、圆角及内边距对齐 IDEA HelpTooltip;隐藏与显示分支使用 IDEA ExpUI 的 chevronLeft/chevronRight 明暗图标;竖栏宽 36pt,展开态按钮为 22pt 且四周保留工具栏内边距,展开态分支树左边框复用与 Commit 标题下边框同源的 1pt 分隔线;收缩态竖栏常态复用展开态侧栏背景,展开与收缩保留提交图谱和详情视图实例、滚动状态及分支宽度,仅切换分支面板与分隔条的占用宽度,按钮占满竖栏,深色 hover 使用 Islands Dark 的 #FFFFFF17,浅色 hover 使用 ExpUI Gray12,不在右侧显示 Show Branches 浮层提示,图标在顶部留 8pt 并使用常规小字号文字;展开后恢复分支树宽度。 使用原生 NSHostingView 渲染验证共享 LitheSearchTextField 的占位文字在深浅主题均为 IDEA Component.infoForeground 对应的 #73767C、13pt 常规字重;空输入框单独绘制占位文字,避免 SwiftUI 原生 prompt 替换其颜色与字重,有内容时占位文字消失并保留原生编辑和主文字色。 Git Log 分支树按 IDEA Community Islands 普通密度核对 24pt 行高、无行间额外间距、13pt 常规文字、12pt 次要计数与 4/12pt 树边距;展开箭头、路径文件夹、普通分支、当前分支和标签使用上游 16pt 明暗 SVG,Local/Remote/Tags 标题不附加图标,当前分支不显示额外蓝色勾选;HEAD 与当前分支是两个互斥选中节点,点击分支、HEAD、清除筛选和切换仓库时核对选中状态;深浅主题核对树行焦点/失焦选中色及 hover,保留多仓库名称、圆点、数量和只读菜单,移除分支行仓库色条;Windows 多仓库分支树的仓库行与 macOS 一致,仓库行使用中性色文件夹图标,并只在图标与名称之间显示 8px 仓库色点,仓库名保持普通文字色,不出现整组着色卡片底色、左侧色条或彩色名称,截断名称通过共享工具提示显示全名,行悬停为箭头光标;确认搜索、分组折叠、右键操作、缓存行比较和滚动状态正常。 Git Log 分支树右侧分隔线与 Commit 标题下边框共用 LitheTheme.toolWindowBorder 和 1pt 厚度,深色为 #26282C、浅色为 #E9EAEE;悬停、拖动开始/移动/结束均保持同色,不高亮,保留原生调整光标、命中区域、拖动尺寸约束及提交宽度行为。 Git Log 中间栏按 IDEA Community FilterComponent、VcsLogGraphTable 和 PaintParameters 核对四个筛选器的 13pt 常规文字、4pt 内边距、16pt 箭头和仅文字悬停反馈;工具栏使用 16pt IDEA 明暗 SVG、22pt 点击区域和共享提示,保留动作及禁用条件;提交列表为 26pt 连续行,图谱尺寸同比缩放,作者与日期同为 13pt 主文字色,日期列按打包字体度量,核对深浅主题行 hover、焦点/失焦选中色及选中覆盖 hover,筛选、分页、箭头命中、上下键导航和右键操作不回归。 分支竖栏设置齿轮复用 LitheIconButtonStyle 的 22pt 点击区域、4pt 圆角和主题 hover/按下背景;点击使用 LitheContextMenuPresenter 的共享操作菜单背景、1pt 边框、行 hover 与键盘导航,保留 Fetch Options 对话框、Show Worktree Repositories 勾选和无工作树时禁用行为,点击外部或按 Esc 关闭菜单。 macOS 下拉菜单仅保留 Project 同源的一套全局共享样式,移除 settingsStyle 切换;Project、Git Log 设置、Terminal、欢迎页及右键子菜单统一使用 8pt 外框圆角、1pt 内描边、24pt 行高、12.5pt 文字、6pt 外留白和 8pt 行内边距,设置选择下拉框共享同一外框与尺寸定义; Git Log 顶部按 IDEA 恢复 Branch: 已选分支名称,保留 Branch 筛选、清除和菜单内勾选;Branch、User、Date、Paths 按 IDEA FilterComponent 保留 4pt 内边距、3pt 箭头间距和 13pt 常规文字,四项文字 hover 为白色且不增加底色。Date 使用共享菜单呈现器,Branch/User 的可搜索列表与分组子菜单使用共享 LitheDropdownRowStyle、24pt 行高和共享菜单外框,Paths 输入面板复用共享菜单外框及搜索输入框样式,保留搜索、选项选中、路径 Apply/Cancel/Clear 和时间范围计算。 Branch/User/Paths 原生弹窗锚点不参与鼠标命中,核对按钮与文字收到 hover/点击、菜单正确弹出且关闭后可再次打开;Date 保持共享菜单呈现器。共享下拉外框裁剪内部内容,明暗主题下 Branch/User 搜索条不能覆盖圆角;Paths 输入框复用共享输入样式并显示正确焦点边框,Clear/Cancel/Apply 复用共享次按钮/主按钮,保留路径应用和清除行为。Branch、User、Paths 的可搜索内容同样使用 LitheContextMenuPresenter 的透明无边框面板,去掉 NSPopover 系统外框,复用 Project 共享背景、1pt 边框和圆角;分组展开与搜索动态调整弹窗尺寸,Esc、点击外部和切换菜单正确关闭。选择分支后清除筛选,确认 Branch 恢复默认标题且关闭按钮消失;关闭按钮保留 16pt closeSmall 明暗 SVG、22pt hover 区域及 4pt 圆角。展开分支树左侧固定线、中间分隔线和右侧详情拖动线均使用 toolWindowBorder 的 1pt 边框,右侧 hover 与拖动不高亮。右侧详情展示图标使用 IDEA previewVertically 明暗 SVG,装饰开关使用 show 眼睛而非 hide 工具窗口减号;所有工具栏展示图标复用 22pt、4pt 圆角的共享 hover 背景,保留原动作与提示。深浅主题渲染核对背景和边框,保留可选图标、勾选、快捷键、禁用、子菜单和键盘导航。 Git Log 提交标题、作者和日期使用 Inter 13 Normal,引用标签 12pt;核对至少 26pt 的字体度量行高、含 leading 的整数基线、长标题与中文/emoji 截断,以及选中合并提交的文字颜色。 所选分支存在时 Log 标签显示 Log: 分支短名(包含 codex/ 路径),选择另一分支立即更新;清除分支筛选后恢复 Log,保留本地化标题、原始分支名和原标签选择/焦点行为。 macOS 标题起点按缩放图谱列距、图文间距和 2pt 文字内边距计算,为对齐参考截图至少预留六列,密集行继续扩宽,不改变图谱节点、连线和箭头命中;在 SwiftUI/AppKit 两条渲染路径核对未选中的合并提交标题、作者、日期统一使用合并灰色,选中后恢复普通文字色,合并判定仅依赖至少两个父节点。 Git Log 右侧文件树使用共享 24pt 行高、19pt 层级缩进、常规字重、文件类型图标和 IDEA FileStatus 文件名颜色,无逐行横线及工具栏重复总数;核对文件夹折叠、文件打开 diff、长名称 hover 展开与横向滚动,拖动宽度不重建行内容。提交详情使用 14pt 外边距、10pt 内间距、等宽 bold 标题、同段作者邮箱时间与引用标签,长内容可滚动;文件树/详情之间分隔线复用共享边框,hover/拖动不高亮。左侧分支树从 180pt 专用下限改为共享 30pt 下限,独立 36pt 竖栏保持原宽,窄树裁剪后可拖回原宽,收缩/展开不重建图谱。 图谱圆点、连线、箭头按 SimpleGraphCellPainter/ PaintUtil 的 FLOOR/ODD 物理像素规则对齐;在 1×/2× 原生位图验证圆点与线宽,在真实 NSHostingView 检查对齐后的上下斜向箭头尖端及内侧描边可导航,切换屏幕只重绘且绘制/命中坐标一致。 时间列复用 Inter 13 常规字体的等宽数字与固定 AM/PM 区域,按应用语言使用英文 12h AM/PM 或中文 24h 格式;核对午夜、正午、未知日期回退、行起点一致及切换语言后的原生日期缓存失效,列表两条渲染路径和提交详情使用相同格式。 连续上下拖动 Git Log,包含上方长 Diff:原生列表只调整可见区域,保持文档身份、滚动位置、Shift/Command 多选、焦点色、键盘与箭头导航、分页和辅助功能;收缩再恢复后列表宽高正确。GitGraphInteractionTests 使用 300 条提交、80 次原生尺寸变化和共享分隔条事件验证,局部新旧路径计时作为诊断,不代替目标工作区帧率验证。 共享分隔容器按已有宽高直接分配两个面板与分隔条的确定矩形,避免 HStack/VStack 最小及理想尺寸探测;splitPaneBounds 覆盖横纵方向、leading/trailing、折叠、子视图身份和有限尺寸,达到尺寸限制后的相同结果不重复写状态。 通过键盘或程序化切换焦点时 Git 标签活动态双向更新;挂载或重新显示 Git Log 不主动抢走编辑器焦点。 在包含展开分支树的 Git Log 中连续拖动外层高度和内部宽度:共享分隔器只在拖动开始/结束传播环境状态,嵌套容器继承祖先状态;拖动期间共享行悬停不更新、提示不登记几何锚点、右键覆盖层暂停,松开后恢复菜单和提示,行内容及滚动状态不重挂载。69 行原生分隔条事件回归检查覆盖层暂停/恢复及内容身份;未悬停控件在平时同样不登记提示锚点。用目标工作区 Time Profiler/Animation Hitches 对照 Terminal 核对持续更新成本及起止开销,split.drag 整次手势时长不能当作单帧延迟;本次仅前端共享交互装饰调整,不修改后端及默认详情高度行为。 中文输入法组词期间,即使绑定文本仍为空,共享 LitheSearchTextField 占位文字立即隐藏;取消组词或删空后恢复,确认中文后仍隐藏。原生 setMarkedText 回归覆盖明暗主题和两个输入框互不影响;保留焦点、键盘提交、搜索/过滤语义及占位字号颜色。原生背景观察视图卸载和移出窗口时清理通知,匹配当前窗口的字段编辑器及所属输入区域,不修改业务绑定。 四个筛选弹窗均以各自按钮左下角为定位锚点,Date 不依赖鼠标点击坐标;空间不足时限制在屏幕可见范围内。原生面板回归核对操作菜单/可搜索内容相同锚点下的左上角、无展开动画和 Esc 关闭回调。共享搜索字段在未聚焦时悬停也显示文本编辑光标,离开或禁用时恢复箭头。 Git Console 左侧六个现有动作使用 Community 原始 16pt 明暗 SVG;22pt 背景、竖向 2/1 按钮留白、5/7 外边距和默认箭头光标。核对查找、软换行、跟随、停止、清空、复制的原有动作与禁用状态,组件资源检查不替代完整应用验收。 按 Community CurrentBranchHighlighter 标出当前本地分支可达的所有父提交,包含合并父节点;深色 #1D2336、浅色 #EDF3FF,选中背景优先,仅已加载图谱可证明的祖先被标记,当前分支/HEAD 单独筛选时不重复染色。引用默认显示并按 GitRefManager/SimpleRefGroup 紧凑合组:本地与上游同提交显示 remote & branch,HEAD/本地/远端/标签使用官方黄/绿/紫/灰轮廓及叠层,标签单独存在时默认只显示图标;长名称按列宽和 22 字符下限缩写,原生可见区 tooltip 保留所有完整名称,滚动后按当前鼠标位置解析。明暗原生渲染检查颜色、宽度、选择优先级及完整名称;GitLogReferenceResizeTests 在真实 GitLogView 中加载 1000 个分支并拖动外层高度,检查可见右键覆盖层数量和挂载生命周期,计时仅作诊断。最新正式预览已进入该工作树,观察全部引用下的深色背景、叠层缩写标签和多次上边缘拖动后的布局恢复;用户随后在本机明确确认“现在不卡顿了”,本次报告的高度拖动卡顿通过用户实机验收;组件计时和混合工作区采样不用于推断唯一根因或量化通用帧延迟,其他主题/悬浮等视觉项继续按各自范围验收。 在 Windows Git Log 选中带多行正文的提交,确认右侧详情在标题下方完整显示正文(保留空行与缩进),复制提交信息和打开提交 Diff 时也包含正文;分支最新提交的图谱连线从提交圆点开始,不超出到圆点上方;在双端使用同一包含本地分支、远端引用、标签和合并提交的仓库,核对永久图布局、图头引用排序、合并边投影及跨越 30 行的紧凑长边;在本地分支新增提交后确认分支颜色保持稳定,且不会因共用屏幕泳道直接沿用父分支颜色。双端使用 Community 完整颜色 ID 及明暗主题 RGB 规则。 读取提交正文期间切换仓库、重新打开另一提交或关闭面板,确认迟到结果不会打开旧 Diff 或覆盖新请求的加载状态。 Windows 另验证:单击提交后编辑区预览该提交第一个文件的 diff;单击或双击 Commit files 中的文件只显示该文件的 diff(不含提交说明,也不显示文件列表),并复用同一个预览标签;Commit files 树中过长的文件或目录名不折叠为省略号,区域随最宽行横向展开,可通过横向滚动条或触控板侧滑左右滑动查看完整名称(与源代码管理变更树一致);Git Log 刚打开、尚未点击提交时不会自动打开 diff;日期列将有 UTC 偏移的提交转换到本机时区后显示相对时间(刚刚、N 分钟前、今天/昨天);英文绝对日期和时间通过 Windows 原生接口遵循系统短日期/时间及用户自定义格式,中文使用中文地区格式,未知偏移仍显示绝对日期;验证美式月/日/年、英式日/月/年、自定义分隔符、12/24 小时制、跨时区相对时间和迟到原生结果保护,真实 WebView2 产品验收为 pending;鼠标移入行时刷新相对时间;作者/日期列可在行内列边缘拖动调整宽度并在重启后保留。 非连续多选提交修改同一路径时,预览保留每个提交的 diff 和提交标识,可通过文件导航分别查看;延迟请求返回前取消选择、隐藏 Git Log、切换仓库或卸载工具窗,确认旧请求不会重新打开或激活预览标签。 Windows 端提交历史仅通过 Git Log 工具窗浏览:源代码管理侧栏入口已更名为 Commit 面板,其 History 标签已移除,面板固定显示变更列表与提交区。命令面板中的 Git: Show History 入口同步移除。 Windows Commit Files 单文件预览使用独立页面:上下箭头导航差异,下箭头在当前文件最后一处后继续进入下一文件并在比较完成后定位第一处差异,整个文件集合末尾禁用且不循环;图片、二进制和无文本差异文件也允许下箭头继续,比较未就绪时禁用以防连续点击跳过文件。左右箭头直接切换当前比较集合的上一文件/下一文件;标签使用 IDEA 的 Repository Diff: 文件名并跟随导航更新,不附加提交 hash。Jump to Source 按最后聚焦侧的补丁位置打开预览所属仓库的文件,重命名使用新路径、删除行映射邻近保留行、已删除文件禁用源跳转;模型更新期间禁用差异动作。保留并排/统一视图、空白显示、Monaco 查找、图片和二进制呈现,普通全量提交比较仍使用多文件页面。真实 WebView2 内核及源文件打开还需目标产品运行验收。 Windows 单文件历史 Diff 外观验证:并排视图使用独立外侧 12px 滚动轨道、8px 滑块和概览,通常的统一视图保留 Monaco 原生 Diff 组件,整文件新增使用真实新行流的独立只读控件,深浅主题检查常态/悬停/拖动色、圆角及边框;实际拖动任一并排滑块后按差异边界同步对应行且模型身份保持。工具栏使用现有 Button,核对 40px 高度和 22px 图标按钮;保留用户字体与字号,默认行距按 14px 字号对应 22px 并随缩放,自定义行距不覆盖。词级高亮开关复用现有 Monaco 装饰能力,关闭只隐藏字符差异、保留整行差异,切换文件保留词级和空白开关。旧/新版本标题显示真实第一父提交、范围基线/目标或非连续提交各自身份,根提交旧侧为空树,重命名显示旧/新路径;短 hash 和截断路径的 tooltip 保留全文。并排标题列宽由独立布局所有者更新 CSS,拖动分隔条时标题跟随且不重建模型;统一视图标题纵向排列。以上浏览器真实组件验证不替代目标 WebView2 产品验收。 Windows 单文件 Diff 滚动条回归:两侧横纵滚动条默认显示,鼠标移到工具栏后仍可见,不依赖悬停;差异概览不绘制重复的宽矩形视口指示,并排由独立外侧轨道负责点击、拖动和滚轮,统一视图保留原生委托。明暗主题、并排/统一视图及长文本双向溢出下检查唯一可见滑块、并排横向同像素偏移同步、纵向对应行同步和模型身份。 历史 Diff 两侧滚动轨道与代码编辑器概览画布背景透明,鼠标不悬停时滑块仍显示;关闭代码编辑器重复概览通道,但保留 Diff 专用差异色条。横向轨道不额外增加内容高度,检查代码能显示在滑块后、底部内容与滚动位置正确,拖动命中保留,并排两侧横向同像素偏移同步、纵向对应行同步。 Windows 并排单文件 Diff 使用两个独立只读 Monaco 代码控件,取消 DiffEditor 的补空白对齐。左右横向滚动按同一像素偏移双向同步,较短侧由 Monaco 钳制到真实内容边界且不反向拉回主动侧;纵向原生代码区、外侧滑块拖动/点击、轨道键盘、滚轮和查找以视口三分之一处为锚点,按 Git 差异块起止边界同步对应行并保留行内偏移,短侧在不等长块内钳制、共同上下文恢复对齐。同步有重入与微小方向保护;双模型替换、布局、字体配置和显式上下导航期间暂停同步。新增旧侧/删除新侧画横跨可见代码区的双像素零行边界,修改区画上下单像素边界;两列行号背景为直边,曲线只在两列之间弯曲,实际偏移改变端点形状。检查文件开头/末尾零行、三态、明暗主题和窄列,代码不补空白、不扩展横向范围;连接面覆盖两列历史行号背景,行号选择和源映射正确。左右外侧各显示透明常显纵向滑块与增删改概览,横向保留原生滚动条,滚动范围截止真实最长代码行。验证深浅主题、折叠展开、Ctrl/Cmd+F 搜索折叠文本、词级开关和预算、统一视图及跨文件首处定位、连续拖动和窄窗口非负尺寸。高频帧二分筛选可见差异,缓存像素边界及概览,不扫描全文、不更新 React;卸载和迟到语言准备清理所有帧、监听、观察器、拖动、两个编辑器和模型。浏览器生产组件验证使用平台记录器,真实 WebView2 产品验收仍为 pending。 外侧轨道预留独立空间,不显示代码;左轨道距面板边缘、右轨道距代码视口各留 4px 间隙,窄列随可用宽度缩减,右侧文字与轨道不重叠;并排和统一预览关闭缩进及括号引导线,保留语法颜色;中央行号缩小边距和曲线间隙,整数布局边界及上下半像素描边消除与代码区的垂直接缝。滚轮在代码、行号和轨道统一加快到两倍,拖动仍映射各侧真实进度,纵向同步对应行;方向键按用户行高移动。有词级结果时修改正文底色按 40% 修改色与 60% 页面背景混合,完整修改色突出替换词的两侧,纯新增和纯删除词分别使用完整增删色,语法前景色和文字透明度保持;关闭词级或超限保留整行底色。验证三态与开头末尾、双向对应行同步、明暗主题、轨道无遮挡、宽窄字体布局和预算回退。 单文件并排及统一视图隐藏补丁 @@ 标题,但保留真正以 @@ 开头的源码、行 ID、源行映射和原始补丁;默认多文件与暂存投影不变。Islands Dark 继承 Darcula 背景,Islands Light 使用 Light 方案,独立差异轨道标记与连接、代码边界共用对应差异背景色。底部保留五个用户实际行高的 padding,模型不增加假行;从任意侧滚到底部验证共同末行对齐与五行留白,字号/行距变化同步更新。 Windows 单文件 Diff 首次打开、左右切文件和同路径新比较均在模型/比较准备完成后定位第一处改动;定位只消费一次,调整词级、空白、字号或主题保持用户当前位置。统一视图的原生 Monaco 增删行、字符与行号栏使用该预览相同的 Islands 背景变量,移除默认字符边框;新增整文件应为深色 #294436 或浅色 #BEE6BE,删除为 #484A4A 或 #D6D6D6,语法前景色不变且其他编辑器主题不被覆盖。 整文件新增采用单流只读代码控件,隐藏不存在的旧侧与连接带,新增背景覆盖行号、代码和底部留白,避免空旧模型的灰色删除行及外圈;新增仅显示新版本、删除仅显示旧版本的一组 hash 与路径。并排两侧及新增单流轨道的增删改标记与对应内容背景共用颜色;原生统一预览关闭 renderIndicators,历史行号旁不显示 +/-。这组新增显示修复按用户要求延后运行验证,提交或 PR 前核对新增文件、普通修改、删除、深浅主题、查找、源跳转与底部留白。 Windows Git Log 单文件和 Commit 文件 Diff 的词级高亮、显示空白符、统一/并排切换均在左侧,最右侧统计当前文件差异,区分无差异/单数/复数;Commit 勾选、部分包含、取消及刷新后 included 数同步变化,全部包含仍显示数量;加载、切换文件及图片/二进制不显示文本差异统计。核对中英文、明暗主题、窄窗口和按钮选中/禁用状态。 Windows 单文件 Diff 上箭头在首处继续进入上一文件最后一处,下箭头在末处进入下一文件首处,集合首尾不循环、加载中禁用;Commit 文件列表随跨文件导航更新选中行并展开祖先、滚动到可见位置,保留编辑器焦点和 include 状态;同文件刷新、历史 Diff、无关仓库和迟到读取不扰动列表。 Windows Git Log 右下角 Commit files 列表同样跟随 Diff 的上一/下一文件导航:选中行移到当前文件,被折叠的父目录自动展开,行滚动到可见位置;预览属于其他提交或范围时不改变选中,点击行不会改变横向滚动。 Windows Git Log 筛选后基于完整已加载历史投影可见祖先:隐藏中间提交以虚线连接,直接父子保持实线,无关分支不误连;合并路径去重并保留永久颜色,未加载父提交经隐藏节点传播,分页补齐后解除缺失标记;清空筛选恢复原图,核对文本、作者、分支名称三种范围、空结果与选择行为。算法和真实表格组件回归通过不代替 WebView2 原生验收,原生验证保持 pending。 Windows 未筛选图与筛选图共用上下半边打印元素:普通浏览的跨行泳道换列必须在共同中点连续连接,合流入边保留各自颜色到提交圆点;核对原始 IDEA 200 条历史输出的列号、方向、终止和颜色身份;截图/原生交互验收仍为 pending,组件输出和 golden 对照不代替 WebView2 验收。 Windows Git Graph 外观:核对明暗主题真实 IDEA RGB、实心节点、直线与筛选虚线、终止箭头及至少六列标题预留;默认 26px 行高,用户字号变化时虚拟行与 SVG 同步扩高;在 100%/125%/150%/200%/300% 缩放及跨屏 DPI 变化下核对奇数物理像素和相邻半边连续性,普通视口调整不重建历史图。箭头能跳到已加载且可见的父/子提交,未加载父节点没有可点击目标;浏览器生产组件验证不代替目标 WebView2 运行验收,原生验证保持 pending。 Windows 历史排序和图导航:在交错分支仓库核对首批/分页/回退及全引用上下文均使用日期顺序,切换分支保持可证明的永久颜色和基础顺序;上下文最多 5000 条,覆盖不完整或哈希重复时保留可见页并回退。核对 upstream/backup 等非 origin 远程引用分类及本地含斜杠分支;背景上下文不阻塞 50 条可见页,分页不取消或重读上下文,切仓库/刷新/卸载取消旧操作且关闭迟到游标。长边开关展开/收起不改变提交、筛选、选择和游标;验证 30/1000 行边界。点击或用 Enter/空格激活上下箭头,选择并滚动到屏幕外端点,挂载后键盘焦点随目标;不误选源行、不误开源行 Diff,保持普通选择/多选/双击/右键和原预览入口。明暗主题及 1x/1.25x/2x 检查箭头尖端与命中范围,真实 WebView2 运行验收保持 pending。 图谱颜色必须跟随 ThemeRegistry 根 data-theme-type 切换;不依赖页面存在 dark class。复用真实 Lithe 明暗主题检查同一已挂载节点与连线的颜色变化、布局不因主题重算,结合主题回归和浏览器真实切换验证。 Windows 分页稳定性:选中顶部提交后向下滚动触发连续分页,确认滚动位置不跳回已选提交,Commit Files 不清空或重读,已选文件及树折叠保持;更新引用、背景上下文和相同 hash 的元数据同样不导航。定位分支头通过独立请求仍能定位已经选中的头提交一次;新选择或切仓库仍读取新文件并丢弃旧结果。组件回归与真实浏览器虚拟列表/IntersectionObserver 验证通过,目标 WebView2 实机验收保持 pending。 Windows Git Log 标题栏不显示固定 Read-only/只读文字,关闭按钮保持靠右,刷新、设置及隐藏操作正常。 Windows Git Log 单个提交右键 New Tag… 输入非空且无空白的标签名,创建指向右键提交完整 hash 的轻量标签并刷新引用和历史;取消不写入,失败保留名称可重试,双击/Enter 不重复创建,多选和写操作期间禁用。仓库或工作区切换关闭旧弹窗,旧请求迟到不得刷新或关闭新弹窗。 Windows 提交区域点击后上下箭头更新可见提交选择和详情,焦点不随虚拟行移除而丢失;筛选、首尾边界、Home/End、Shift 范围选择和 Enter 正常,菜单与输入框保留自己的方向键。 Windows Git Log 鼠标或上下键选择提交后,异步 Diff 自动定位第一处改动但保持提交列表键盘焦点;并排与统一预览均不调用初始 focus。双击/Enter 打开完整 Diff、主动差异跳转及跨文件导航仍进入编辑器。 Windows Git Log 提交右键 New Tag 使用与 Tags 节点同源的 TagIcon(沿用现有标签轮廓图案),核对 16px 图标、菜单对齐和禁用反馈;新补图标的实机视觉确认待完成。 Windows 提交列表菜单键和 Shift+F10 打开当前选中提交的真实菜单;关闭后列表继续上下键导航,菜单操作仍针对所选提交。New Tag 在 tag.gpgSign=true 下生成轻量标签,不运行签名器或消息编辑器,不修改配置。 Windows 提交行高亮和紧凑引用组:在全部引用和其他分支视图核对当前检出分支全父祖先背景,当前分支/HEAD 视图关闭重复高亮;合并提交的说明、作者、日期未选中时弱化、选中后恢复,选中背景优先于分支并区分列表/文件树/窗口焦点。核对明暗主题固定基准色、真实 upstream 合并名称、游离 HEAD、每种最多两个叠加图标、仅标签图标和完整汇总悬停/无障碍提示。宽窄列及字号变化时按至少 22 字符缩略规则布局,只有一个视口尺寸观察器,列拖动不逐行读取宽度,卸载清理;分页不丢滚动/选择,成功后不重读 Commit Files;文件读取失败时 Commit Files 面板显示重试入口,重新选择同一提交或刷新历史也会重试一次,长边导航和新建标签原入口保持。组件与浏览器验证通过,目标 WebView2 实机验收 pending。 Windows Git Log 分支树和提交列表的普通滚轮使用 Community Windows 默认 200ms 和 (0.5,0.505,0.5,1) 曲线;连续同向累积、反向从当前位置重启。核对两处列表的中间帧、Shift 横向滚动、分页保持、顶底边界、键盘定位和滑块拖动取消惯性、关闭工具窗清理帧以及减少动态效果偏好。确定性动画与 DOM 回归通过,真实 WebView2 设备手感验收保持 pending。 Windows graph 标题不再固定预留六列:建议宽度取可见图边数的加权均值与标准差,最多以六列作统一基线,每行按节点与斜边中点扩展,密集行不把其他简单行扩成最大列宽。验证单线/少分支、罕见密集合并、超过六列、筛选、长边开关、引用标签可用宽度及字号/DPI,保持图谱颜色/连线/导航不变。 Windows Git Log 的 Commit Files 文件树沿用 IDEA Windows 默认 200ms 滚轮动画;在文件行、竖向/横向滚动条区域连续滚动、反向及 Shift 横向滚动,确认共用真实视口的动画目标,长文件名保持自然宽度;按下滚动条取消未完成惯性,减少动态效果时直接滚动,切换提交及卸载不残留帧。其它 ScrollArea 默认行为不变。真实 WebView2 交互验收 pending。 Windows Git Log 右键 New Tag 打开弹窗后焦点直接位于标签名输入框,无需点击即可输入,Enter 提交、Esc 关闭。 macOS Git Log 空状态:在非 Git 项目检查明暗主题、窄窗口和键盘操作:13pt 常规文字按 IDEA 左对齐,整组位于内容区上方三分之一处;显示 To track changes to code、GitHub/GitLab 官网链接、Initialize Git repository…、Open Git Settings 和带原始 ContextHelp 图标的 Version control integration(打开 Git 官方文档)。初始化仍先确认,不自动暂存或提交;设置打开既有 Git 设置。未提交仓库、无匹配提交、加载失败及重试保持原动作,所有空状态操作采用文字按钮。 非 Git 项目空状态隐藏 Log/Worktrees/Console 标签、添加按钮、分支树与动作条、筛选/搜索工具栏及提交详情,提示占满工具窗内容区;GitHub、GitLab、初始化、设置及帮助链接悬停仅给当前文字加主题强调色下划线并显示手形,离开后恢复;初始化或切换至真实仓库后恢复原有三栏布局,真实仓库无匹配提交仍保留筛选入口。 空状态字体与间距对照 Community c7f91397:按钮标签显式使用 Inter 13pt Regular;行首破折号按首行基线对齐,21pt 行高加 2pt 间隔,帮助图标间隔 2pt;灰字与链接分别沿 Component.infoForeground 和 Islands Link.activeForeground 核对明暗主题,悬停下划线仍使用当前主题强调色。 macOS 右侧提交详情的分支标签按可见区域懒加载,全部引用仍可滚动查看。重开面板初始化时恢复匹配的提交图和分支树,第一次布局即可读取全部已缓存数据,不依赖出现后的异步任务回填。重开面板复用未变化的分支树,单仓库不重复构建分组副本,多仓库活动根复用已有三类行;引用、仓库、工作树开关、折叠状态改变后拒绝旧树。原生绘制与无障碍日期文本复用缓存,语言改变后刷新。 macOS 大量引用首屏:同提交放置 1,500 个本地分支和 1,500 个远程引用,核对真实 upstream 优先、同名远程自然排序回退、完整提示及每类图标上限;反复切换 Terminal/Git Log,数据版本相同应复用已准备图,改变分支/筛选/图显示选项后不得复用旧图。运行 GitGraphInteractionTests 的 manyReferenceGroups 和 presentationCache;组件耗时仅诊断,整机卡顿以相同数据实测为准。 macOS Git Log 及终端按需创建后由工作台持有实际原生宿主;隐藏再重开及移动停靠位置复用控件。运行 GitLogReferenceResizeTests,验证同一工作台隐藏再重开时,固定原生表面上的提交文档和滚动容器对象身份不变,恢复可见性且尺寸正确,工作台释放后宿主释放;核对语言、主题、搜索、分支操作和终端会话。 Git Log 与终端同时停靠时,从外层横向和纵向分隔条中央及向面板两侧偏移 4pt 处,经窗口发送按下、拖动、松开,确认完整 10pt 命中区仍能提交尺寸、宿主身份保持,面板中央正常交互。;macOS 保留宿主圆角需在明暗主题、侧栏顶部与移动后、项目辉光改变、渐变开关及背景图切换时,与原工作台树四角像素一致(WorkbenchSurfaceBackgroundTests.retainedPaneCornersMatchWorkbenchGradient)。 Windows HEAD 按 Community HeadNodePainter 核对外圈、背景间隔和中心实点:26px 行高、100% 缩放时三层直径为 13/9/5px,125%/150%/200%/300% 按物理像素 FLOOR/ODD 对齐;深浅主题、悬停、当前分支及活动/非活动选择均透出真实行底色,穿过 HEAD 的连线不侵入间隔。普通节点及分叉、筛选、长边展开保持;同边双向终止元素键唯一。目标 WebView2 实机验收保持 pending。 macOS 在明暗主题的窄 Git Log 工具栏中选择长用户名、分支和路径,确认名称与选中值以同一行尾部截断,文字不重叠,清除按钮和重新选择仍可用。 macOS Git Log 接近底部时自动追加较早提交,正常浏览不出现必须点击的加载更多按钮;单一页面最多发起一次边缘请求,追加保留选择和原生视口偏移。无新提交或缺失后续游标时停止并释放游标;失败暂停自动读取,显式刷新重开历史而不重用失败游标。运行 GitGraphInteractionTests.automaticHistoryPaging 与 GitModuleTests.continuousHistoryPagingStopsOnDuplicatePagesAndRefreshesAfterFailure,真实大仓库连续滚动和 Windows WebView2 验收仍 pending。 macOS 深层历史后台刷新:文件状态变化不重开首批,元数据刷新保留已加载窗口和后续页占位,未变结果不重建提交图;外部新提交按可见 hash 与行内偏移保持原生视口,按新行位移补齐旧尾部,保留尾部选择。当前仓库引用只读取一次,多仓库仍独立加载。后台刷新打断自动分页后,即使历史相同也能继续读取新游标;失败仍暂停自动重试。运行 GitModuleTests.backgroundRefreshRetainsDeepHistoryAndSelectionWhileExternalCommitsStillAppear、引用聚合回归及 GitGraphInteractionTests.backgroundHistoryRefreshAnchorsVisibleCommitInsteadOfSelectedCommit/automaticHistoryPaging;真实大仓库长时间滚动仍待用户验收,原生进程 cleanup 超时未独立复现,不将减少重复查询等同于修复所有进程失败。 macOS #1542:显示保留的 Git Log/终端时,横纵分隔条中央及两侧偏移 4pt 仍经窗口事件完成拖动且只提交一次,宿主身份不变;根命中查询深度始终为 1,面板内部连续 100 次查询不产生额外根查询,鼠标移动不回查祖先 SwiftUI。验证禁用、收起(含嵌套分隔条)、恢复、卸载、跨窗口与登记表隔离、实时移动/裁剪、隐藏/透明和弱引用释放;保留宿主内部仍正常命中,外层边缘优先。Diff 两端收起后在普通与保留侧栏下均能经窗口拖回,不触发外层拖动。运行 GitLogReferenceResizeTests、SplitHandleHitTestTests 和 DiffScrollSynchronizationTests;旧实现先出现嵌套命中断言失败,新实现通过。较新 macOS 原生组件回归不替代 macOS 13 Intel 原报告崩溃验收,目标环境验证保持 pending。 历史菜单资格使用 Core 读取真实 HEAD 与第一父链;在筛选/分页、旁支首行、跳选、切换仓库、HEAD 变化和关闭菜单时验证动作状态及迟到结果隔离;两端原生界面验收 pending。 Git 控制台执行日志的记录状态(completed / unconfirmed)、单条与总量保留预算和脱敏由 Core 事件携带,两端不再各自归约或二次脱敏,单条输出预算统一为 32768 字符。 历史刷新的窗口大小、头部新增后保留旧尾部的延伸读取、翻页合并去重与上限、选中提交/焦点/范围锚点的保留统一由 Core `git.historyWindow` 决定;Windows 监听刷新不再把深层历史缩回第一页,选中与锚点在仍已加载时保留,像素级滚动锚点仍留在视图。滚动到深处后触发后台刷新,确认窗口深度、选中行与 Shift 范围起点不变;两端原生界面验收 pending。 Viva 改动文件折叠:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestLogChangedFiles|TestGroupLogFiles' -count=1;实机选择一个改动多个目录的提交,收起与展开文件夹、用方向键和双击操作,切换提交后文件夹重新展开。 Viva 提交详情改动文件横向滚动:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run TestLogChangedFiles -count=1 和 scripts/desktop/desktop-go.sh test ./internal/hscroll -count=1;实机选中路径很长的提交,确认改动文件列表可左右滚动、底部显示细滚动条,暗色主题下删除的文件显示为红色而不是灰色。 Viva 提交详情的哈希、作者、邮箱和日期不截断:运行 scripts/desktop/desktop-go.sh test ./internal/workbench -run TestLogCommitDetails -count=1;实机把详情面板拖到最窄,选中作者名和邮箱都很长的提交,确认放不下时换行显示,超长邮箱独占一行并在行内折行,没有省略号。 Viva 控制台:执行提交、推送或工作树清理等写操作后打开 Git 工具窗口的“控制台”页,核对命令、输出、退出码、搜索跳转、折叠、复制和清空;desktop/internal/workbench/gitconsole_test.go 覆盖列表、搜索和清空。 Viva 行标识回归 TestLogCommitKeysKeepFooterInRangeAndSeparate:加载页脚使用独立的合法标识 0,提交从 1 编号,重新排序保留提交标识;升级后的 List/Tree 范围检查不得因分页页脚崩溃。原生三平台长历史分页验收仍 pending。 Git 控制台 TestConsoleRowKeysReserveValidMissingRowIdentity 覆盖列表刷新期间缺失行的保留标识,不与真实行冲突。 Git 控制台开关:运行 scripts/desktop/desktop-go.sh test ./internal/core ./internal/workbench -run 'TestGitConsole|TestConsole' -count=1;实机打开设置 → 版本控制,逐个切换“省略的查询”里的九个开关,确认关闭的类别出现在控制台、打开的类别不再新增记录,执行的命令和失败请求始终显示;切换“显示”里的四个开关,确认查询折叠、无输出提示、临时 -c 配置和仓库名立即按开关重绘,复制全部内容仍带仓库名;重启后开关保持。 在“设置 › 版本控制 › Git 日志”把单个仓库上限调小,打开历史更长的仓库:日志末尾显示超出可读取范围的提示和“调整上限…”,不出现加载失败或重试;点按钮打开该设置,改回默认后日志重新读取。", + "notes": "Viva 的 Git Log 已有提交列表、分支面板和提交详情,其余能力尚未逐项盘点。提交详情的改动文件按文件夹分组,文件夹先于文件,使用与项目树相同的 desktop/internal/treelist 折叠列表:单击箭头、双击文件夹或方向键展开收起,Enter 打开文件差异;切换提交后所有文件夹重新展开。2026-11-14 起分组由 Core git.changedFileGroups 计算(#1814):目录按段比较、文件按项目树的自然顺序排列(v0.1.4 在 v0.1.12 前),顶层目录为空字符串;Stash 和 Shelf 页同样适用。legacy 是迁移前基线,不代表当前实现。 Viva 提交详情的改动文件列表与项目树共用 desktop/internal/hscroll 横向滚动:列宽取最长一行,滚轮或触控板横向滚动,底部细滚动条显示位置;删除的文件在明暗主题下都用红色(Deleted),不再用暗色下发灰的次要文字色,Commit 工具窗口同样适用。 Git 工具窗口新增“控制台”页:按时间列出 Core 记录的 Git 写操作命令、输出和退出码,支持搜索与上下跳转命中、折叠长输出、复制命令或输出和清空;记录哪些查询和怎么显示由设置 → 版本控制的“Git 控制台:省略的查询”“Git 控制台:显示”两组共 13 个开关决定,初始状态与 IntelliJ IDEA 一致;省略的查询类别成功时在 Core 记录时就丢弃,不占控制台保留的记录,省略一个类别时已记录的该类成功查询一并移除(类别由 gitExecution.consoleQueries 传给 Core,宿主用 queryCategory 标注后台分支读取、Git 操作后重新加载、保存后差异刷新和日志路径筛选,其余由 Core 按命令归类,类别名与 Core fixture 的 queryCategories 对照测试);用户执行的命令、失败的 Git 请求、用户发起的操作中失败的查询、意外退出码和未确认的命令始终显示。显示开关由 git.consolePresentation 的 display 参数在 Core 里生效:成功查询的输出超过 10 行才折叠,可设置为短输出也折叠;删除分支、标签、远程分支、贮藏、工作树等删除类命令的配置、进度和输出从不折叠;复制全部内容仍保留完整命令和仓库。控制台工具栏原“隐藏读取命令”开关改为打开这两组设置的按钮。 Git Log 最多读取多少条提交可在“设置 › 版本控制 › Git 日志”调整:单个仓库默认 5000 条,多个仓库混排合计默认 20000 条,可选 1000–100000;上限由 Core `git.historyPage` 的 `maxCommits` 决定,读到上限而历史还有更早提交时返回 `limitReached`,日志末尾提示“已读取 N 条提交,更早的提交超出可读取范围”并提供“调整上限…”打开该设置,不显示加载失败或重试。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { diff --git a/shared/platform-feature-matrix/features/git-multi-repository-change-groups.json b/shared/platform-feature-matrix/features/git-multi-repository-change-groups.json index 0bbd507ba7..078f16d7d0 100644 --- a/shared/platform-feature-matrix/features/git-multi-repository-change-groups.json +++ b/shared/platform-feature-matrix/features/git-multi-repository-change-groups.json @@ -31,7 +31,7 @@ }, "owner": "Git", "verification": "在同一工作区打开多个 Git 仓库,确认变更按仓库折叠分组;只剩一个仓库有变更时仍显示仓库名。仓库级和文件级勾选与 Git 暂存区同步;子模块只有未提交文件时显示提示,不能勾选未变化的引用。", - "notes": "Viva:项目文件夹含嵌套仓库时(含文件夹本身不是 Git 仓库),提交窗口按 Core 的 GroupWorkspaceChanges 按仓库折叠分组,每组有颜色、文件数、暂存复选框和“提交此仓库”;顶部复选框按 Core 的 StageAll 计划暂存全部仓库,状态栏统计所有仓库的更改数(Core 的 FileCount)。子模块未变化引用的提示还未在界面中验证。", + "notes": "Viva:项目文件夹含嵌套仓库时(含文件夹本身不是 Git 仓库),提交窗口按 Core 的 GroupWorkspaceChanges 按仓库折叠分组,每组有颜色、文件数、暂存复选框和该仓库当前分支的标签(与 IDEA 一致,分离 HEAD 显示“分离的 HEAD”);组内不再有单独的提交按钮,主提交按钮提交所有有暂存更改的仓库;顶部复选框按 Core 的 StageAll 计划暂存全部仓库,状态栏统计所有仓库的更改数(Core 的 FileCount)。子模块未变化引用的提示还未在界面中验证。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { diff --git a/shared/platform-feature-matrix/features/git-multi-repository-references.json b/shared/platform-feature-matrix/features/git-multi-repository-references.json index e816404ef4..7b180d581b 100644 --- a/shared/platform-feature-matrix/features/git-multi-repository-references.json +++ b/shared/platform-feature-matrix/features/git-multi-repository-references.json @@ -16,8 +16,14 @@ "desktop/internal/workbench/branch_view.go", "desktop/internal/workbench/gitlog_popover_view.go", "desktop/internal/workbench/gitgraph.go", + "desktop/internal/workbench/gitlog_multi.go", + "desktop/internal/workbench/git_log_repo.go", + "desktop/internal/core/workspace.go", + "desktop/internal/workbench/gitlog_multi_test.go", "desktop/internal/workbench/workspace_repositories_test.go", - "docs/assets/workspace-repositories/README.md" + "docs/assets/workspace-repositories/README.md", + "desktop/internal/workbench/gitlog_limits.go", + "desktop/internal/settingswindow/git_log_limits_view.go" ] }, "windows": { @@ -33,13 +39,19 @@ "desktop/internal/workbench/branch_view.go", "desktop/internal/workbench/gitlog_popover_view.go", "desktop/internal/workbench/gitgraph.go", + "desktop/internal/workbench/gitlog_multi.go", + "desktop/internal/workbench/git_log_repo.go", + "desktop/internal/core/workspace.go", + "desktop/internal/workbench/gitlog_multi_test.go", "desktop/internal/workbench/workspace_repositories_test.go", - "docs/assets/workspace-repositories/README.md" + "docs/assets/workspace-repositories/README.md", + "desktop/internal/workbench/gitlog_limits.go", + "desktop/internal/settingswindow/git_log_limits_view.go" ] }, "owner": "Git", - "verification": "在多仓库工作区打开 Git Log:确认按仓库分组、仓库配色、非活动仓库分组只读,点其它仓库的引用会切换活动仓库且只加载一次,Pull 弹窗可选择远程分支与策略。 Windows 无已保存折叠设置时,单仓库与多仓库的 Tags 默认折叠、Local / Remote 默认展开;手动展开 Tags 后重新打开面板仍保留选择,已有折叠设置继续生效。 Windows 明暗主题中普通本地、远程分支均复用顶部分支按钮的空心 VcsIcon,当前分支勾选、收藏星标、标签与文件夹提示保持可辨认。 macOS 在两个分支名不同的仓库间切换时不得查询旧分支;目标历史读取失败也不能保留旧仓库的提交、分页或文件详情。 Windows Git Log 本地和远程分支右键菜单的拷贝分支名称在删除之前,删除是最后一个操作并单独分组;当前分支无删除入口,执行 Git 写操作时删除仍禁用。 Windows Git Log Tags 标签节点右键菜单最后一组提供 Delete,点击后直接删除活动仓库本地标签,不弹二次确认;失败保留引用和选择,成功后清除被删标签的历史筛选并刷新。非活动仓库及写操作期间禁用;旧工作区/仓库的动作回调不得发起删除,迟到结果不得刷新新仓库或释放新请求状态。 Windows Tags 的 Delete 与分支和提交节点删除复用相同 TrashIcon,明暗主题图标与禁用状态一致。 引用树的 `/` 分组与同级排序(引用先于纯分组,再按自然序,收藏分支及其所在分组优先)由 Core `git.referenceTree` 决定,两端只负责展开、缩进与虚拟化;同一组引用在 macOS 与 Windows 的树结构和顺序一致。 打开本身不是 Git 仓库、内含多个独立仓库的文件夹:标题栏分支入口按 IDEA 样式逐行列出仓库(颜色方块、仓库名、右侧当前分支、›),点一行在其旁边展开该仓库的分支面板,在面板里检出、新建、合并、删除只改变该仓库,其他仓库分支不变;Git Log 提交行左侧显示正在查看仓库的颜色条,路径筛选器下方“仓库根目录”按颜色列出仓库,点击后日志改看该仓库且写操作作用于该仓库。", - "notes": "Viva:项目文件夹含嵌套仓库时(含文件夹本身不是 Git 仓库),标题栏分支入口按 IDEA 样式逐行列出仓库,颜色来自 Core(repository_colors.go),右侧是 Core 读出的当前分支;点一行在旁边展开该仓库的面板(“<仓库> 中的最近分支 / 本地分支 / 远程分支 / 标签”),面板里的检出、新建、合并、删除等写操作都只作用于该仓库。Git Log 引用面板按仓库分组,提交行左侧有正在查看仓库的颜色条,路径筛选器下方的“仓库根目录”列出各仓库并切换日志遍历的仓库。尚未实现:IDEA 的 Common Local / Remote Branches(多个仓库同名分支一起操作)、多仓库提交混排的聚合日志,以及跨仓库的 Update / Push。", + "verification": "在多仓库工作区打开 Git Log:确认按仓库分组、仓库配色、非活动仓库分组只读,点其它仓库的引用会切换活动仓库且只加载一次,Pull 弹窗可选择远程分支与策略。 Windows 无已保存折叠设置时,单仓库与多仓库的 Tags 默认折叠、Local / Remote 默认展开;手动展开 Tags 后重新打开面板仍保留选择,已有折叠设置继续生效。 Windows 明暗主题中普通本地、远程分支均复用顶部分支按钮的空心 VcsIcon,当前分支勾选、收藏星标、标签与文件夹提示保持可辨认。 macOS 在两个分支名不同的仓库间切换时不得查询旧分支;目标历史读取失败也不能保留旧仓库的提交、分页或文件详情。 Windows Git Log 本地和远程分支右键菜单的拷贝分支名称在删除之前,删除是最后一个操作并单独分组;当前分支无删除入口,执行 Git 写操作时删除仍禁用。 Windows Git Log Tags 标签节点右键菜单最后一组提供 Delete,点击后直接删除活动仓库本地标签,不弹二次确认;失败保留引用和选择,成功后清除被删标签的历史筛选并刷新。非活动仓库及写操作期间禁用;旧工作区/仓库的动作回调不得发起删除,迟到结果不得刷新新仓库或释放新请求状态。 Windows Tags 的 Delete 与分支和提交节点删除复用相同 TrashIcon,明暗主题图标与禁用状态一致。 引用树的 `/` 分组与同级排序(引用先于纯分组,再按自然序,收藏分支及其所在分组优先)由 Core `git.referenceTree` 决定,两端只负责展开、缩进与虚拟化;同一组引用在 macOS 与 Windows 的树结构和顺序一致。 打开本身不是 Git 仓库、内含多个独立仓库的文件夹:标题栏分支入口按 IDEA 样式逐行列出仓库(颜色方块、仓库名、右侧当前分支、›),点一行在其旁边展开该仓库的分支面板,在面板里检出、新建、合并、删除只改变该仓库,其他仓库分支不变;Git Log 提交行左侧显示正在查看仓库的颜色条,路径筛选器下方“仓库根目录”按颜色列出仓库,点击后日志改看该仓库且写操作作用于该仓库。 多仓库 Git Log 引用面板每个仓库节点下各有本地 / 远程 / 标签,点其它仓库的分支即在该仓库查看该分支;筛选按钮后的仓库名可点击,列出全部仓库:点名称只看该仓库,勾选多个仓库时日志按提交时间混排(Core `git.workspaceHistoryMerge`,各仓库保持 Git 的原有顺序,加载更多只在末尾追加),每行颜色条是所属仓库的颜色,提交详情、文件比较和提交右键菜单都作用于该行所属的仓库;取消勾选到只剩一个仓库时回到单仓库日志。 勾选多个仓库混排时,读满多个仓库的上限后日志末尾提示超出可读取范围,不显示加载失败。", + "notes": "Viva:项目文件夹含嵌套仓库时(含文件夹本身不是 Git 仓库),标题栏分支入口按 IDEA 样式逐行列出仓库,颜色来自 Core(repository_colors.go),右侧是 Core 读出的当前分支;点一行在旁边展开该仓库的面板(“<仓库> 中的最近分支 / 本地分支 / 远程分支 / 标签”),面板里的检出、新建、合并、删除等写操作都只作用于该仓库。Git Log 引用面板按仓库分组,提交行左侧有正在查看仓库的颜色条,路径筛选器下方的“仓库根目录”列出各仓库并切换日志遍历的仓库。引用面板每个仓库节点下各有本地 / 远程 / 标签;筛选按钮后的仓库名可点击,勾选多个仓库时日志按提交时间混排,混排顺序与提交键由 Core `git.workspaceHistoryMerge` 决定,仓库的选择由 Core `git.workspaceRepositorySelection` 的 `chosen` 决定。尚未实现:IDEA 的 Common Local / Remote Branches(多个仓库同名分支一起操作),以及跨仓库的 Update / Push。 混排时所有仓库合计最多读取“设置 › 版本控制 › Git 日志”中多个仓库的上限(默认 20000 条),读满后各仓库停在当前位置,日志末尾提示超出可读取范围并可打开该设置。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": { diff --git a/shared/platform-feature-matrix/features/git-workspace-staged-commit.json b/shared/platform-feature-matrix/features/git-workspace-staged-commit.json index 07a8e57923..9be06fda70 100644 --- a/shared/platform-feature-matrix/features/git-workspace-staged-commit.json +++ b/shared/platform-feature-matrix/features/git-workspace-staged-commit.json @@ -10,7 +10,12 @@ "desktop/internal/core/gitcommit.go", "desktop/internal/workbench/commit.go", "desktop/internal/workbench/commit_nested.go", - "desktop/internal/workbench/workspace_repositories_test.go" + "desktop/internal/workbench/workspace_repositories_test.go", + "desktop/internal/core/git_workspace_push.go", + "desktop/internal/workbench/gitpush_workspace.go", + "desktop/internal/workbench/gitpush_workspace_view.go", + "desktop/internal/workbench/gitpush_workspace_test.go", + "docs/assets/workspace-repositories/README.md" ] }, "windows": { @@ -20,12 +25,17 @@ "desktop/internal/core/gitcommit.go", "desktop/internal/workbench/commit.go", "desktop/internal/workbench/commit_nested.go", - "desktop/internal/workbench/workspace_repositories_test.go" + "desktop/internal/workbench/workspace_repositories_test.go", + "desktop/internal/core/git_workspace_push.go", + "desktop/internal/workbench/gitpush_workspace.go", + "desktop/internal/workbench/gitpush_workspace_view.go", + "desktop/internal/workbench/gitpush_workspace_test.go", + "docs/assets/workspace-repositories/README.md" ] }, "owner": "Git", - "verification": "勾选两个独立仓库文件,一次提交并推送,验证各自 HEAD 和远程;停止一个操作后其余独立仓库继续,已成功仓库不会回滚。", - "notes": "Viva:提交窗口把 Core 发现的仓库列表随请求交回,由 Core 的 WorkspaceCommitRequest.WorkspaceRepositories 绑定嵌套仓库:首次计划带上全部仓库,ChangeList 范围只提交项目仓库,重试只带失败那次计划过的仓库;文件夹本身不是 Git 仓库时只提交嵌套仓库。每个仓库保留自己的 WorkspaceCommitResult,失败不回滚。提交并推送沿用同一计划;推送和中途停止的实机验证还没做。", + "verification": "勾选两个独立仓库文件,一次提交并推送,验证各自 HEAD 和远程;停止一个操作后其余独立仓库继续,已成功仓库不会回滚。 提交并推送先完成提交,再打开“推送提交”对话框:每个仓库一行(勾选框、`分支 → 远程 : 分支`、待推送提交),没有远程的仓库显示“定义远程”且不能勾选,空仓库和分离 HEAD 不能勾选;选中提交后右侧列出它的变更文件;“推送标记”可选当前分支或所有。确认前远程不变;点“推送”后按 Core 的顺序推送,子模块先于记录它的父仓库,子模块推送失败时父仓库跳过并保留对话框,其余仓库继续。", + "notes": "Viva:提交窗口把 Core 发现的仓库列表随请求交回,由 Core 的 WorkspaceCommitRequest.WorkspaceRepositories 绑定嵌套仓库:首次计划带上全部仓库,ChangeList 范围只提交项目仓库,重试只带失败那次计划过的仓库;文件夹本身不是 Git 仓库时只提交嵌套仓库。每个仓库保留自己的 WorkspaceCommitResult,失败不回滚。提交并推送按 IDEA 的流程先提交、再打开“推送提交”对话框(gitpush_workspace.go),本次提交过的仓库默认勾选;每个仓库的状态、待推送提交、推送目标和推送顺序由 Core `git.workspacePushPreview` 给出,推送逐个调用 `git.push` 并开启子模块发布检查;内核不支持该方法时沿用原来的推送确认。截图见 docs/assets/workspace-repositories/README.md。推送和中途停止的实机验证还没做;“定义远程”只是提示,还不能在对话框里添加远程。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": {