Add a git section to the sidebar - #443
Open
pvitt72 wants to merge 1 commit into
Open
Conversation
Shows the branch with its ahead/behind counts, the last commit and the number of changed files whenever the current document lives in a repository, plus a pull and a commit & push button. The section hides itself when git is missing or the document isn't under version control. Git runs through Gio.Subprocess on the main loop, so no threads and no locks are involved. Output is read as raw bytes because communicate_utf8 would cut it at the first NUL byte, which is what "git status -z" separates its records with. Pull is --ff-only: it can never leave the repository in a state the panel can't explain. Commit & push saves the open documents in the repository first, then asks which files to include, with untracked ones unchecked by default so build artifacts don't get committed by accident. Setzer never stores credentials itself. When an operation fails to authenticate it asks once, hands them to "git credential approve" and retries; a failing credential is rejected again so it doesn't stay in a helper. Without "remember" the credentials only reach git-credential-cache, because an empty credential.helper value resets the helper list. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sam-Fic
added a commit
to Sam-Fic/NeoSetzer
that referenced
this pull request
Aug 28, 2026
共享 git 服务层 setzer/vcs/git_repository.py: - 按仓库根缓存单例,gutter 与侧栏面板共用,避免重复调 git - threading + GLib.idle_add 异步执行;.git/index、HEAD 挂 Gio.FileMonitor(500ms 去抖),终端里的 commit/pull 自动刷新 - diff 基准为 HEAD;保存/切换文档/外部 git 操作触发,键入不触发 Gutter 行级标记(cvfosammmm#216): - 新增行绿条、修改行蓝条、删除行红三角(画在删除点后第一行) - 颜色经 ColorManager 映射 libadwaita 调色板(success/accent/ destructive),明暗主题自动适配 - 性能降级:文件超 5000 行或 diff 变更超 2000 行不逐行映射 Git 侧栏面板(cvfosammmm#443): - 分支、ahead/behind、最近提交、改动文件数;位于 To-Dos 与 Document Stats 之间,无 repo/git 缺失/偏好关闭时自动隐藏 - Pull 仅 --ff-only,脏工作区预检提示;Commit & Push 对话框 勾选文件(untracked 默认不勾),无 upstream 自动 --set-upstream - 写操作按仓库显式信任(git_trusted_repos),凭据不落盘
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a small git panel to the sidebar, between To-Dos and Document Stats.
This is a proposal rather than a request. I couldn't find any earlier discussion about version control in the issue tracker, so if it is out of scope for Setzer please just close this — no hard feelings, and I'm equally happy to rework the scope if you like the idea but not the shape.
What it does
The section only appears when
gitis installed and the current document lives in a repository, and hides itself otherwise. It shows the branch with its ahead/behind counts, the subject and date of the last commit and the number of changed files, plus two buttons:git pull --ff-only, so it can never leave the repository in a state the panel is unable to explain. On divergence it says so and points the user at a terminal..aux,.logand.pdfdon't get committed by accident. It then runsgit add -A -- <selected>,git commit -m … -- <selected>and a push (with--set-upstream origin <branch>when there is no upstream yet).Deliberately left out: diffs, branch switching, a staging area, history. Anyone who needs those opens a terminal.
Implementation notes
Gio.Subprocesson the main loop, so no threads and no locks are involved, unlike the build system.communicate_utf8, which truncates at the first NUL byte — exactly whatgit status -zseparates its records with.git_client.pycontains no GTK.Credentials
Setzer stores no credentials itself. Operations run with
GIT_TERMINAL_PROMPT=0; when one fails to authenticate, the user is asked once, the credentials are handed togit credential approveand the operation is retried. A credential that fails again is passed togit credential reject, so a stale password doesn't stay in a helper.With Remember checked,
approvereaches whichever helper the user has configured (libsecret, store, …). Without it, the operation runs with-c credential.helper= -c 'credential.helper=cache --timeout=900': an empty value resets the helper list, so the persistent helpers never see the password. SSH remotes never show the dialog at all.Testing
Verified against a scratch repository with a local remote: repository detection, status parsing, saving before committing, untracked files staying out of the commit, the commit reaching the remote, and pull. The credential plumbing was checked separately in an isolated
HOME: without Remember nothing is written to~/.git-credentialsand the credential comes back from the cache, with it the credential reaches the configured helper, andrejectremoves it again.Not yet exercised: the credentials dialog against a real remote returning a 401.