Repository navigation
feat: manage branches from the panel - #5
Merged
Merged
Conversation
…rror Every failure path called Debug.error(...), which is not an Engine API. The Engine exposes Debug.log_error, so each call raised AttributeError before the Git message could be logged, and the real reason a commit, a stage, or git init failed never reached the Console. The errors now go through Debug.log_error(...) and carry the plugin's source, so the Console can group and clear them. A contract test scans the plugin sources and fails on any Engine method that does not exist.
The header now shows the current branch, its upstream, and how far the branch has drifted from it. Clicking it opens a picker that lists the local and the remote branches, filters as you type, and switches with `git checkout`. The last row creates a branch from the current HEAD. Every git command now runs on a worker thread and lives in a new `git.py` module, so the render thread only draws the last snapshot it received. The status comes from `git status --porcelain=v2 -z --branch`, which returns the branch state together with the file list and keeps a path that is not plain ASCII literal instead of quoting it as an octal escape. A failed branch operation opens a modal that states what went wrong in one sentence and points at the Console, which keeps the full Git message. The branch name is validated with `git check-ref-format --branch` before it is used.
The usage pages gain a "Switching branches" section in both languages, and the licence page now names the three icons that come from Feather rather than counting them. The README states the Git version the panel needs and why, the roadmap moves the finished branch and asynchronous status items out of "Next", and the contributing guide records that every git call belongs in `git.py` and runs on a worker thread.
The Console error reporting fix ships with the branch workflow instead of as a separate patch release, so the version moves to 0.2.0 and the changelog replaces the 0.1.6 section with one that covers both.
The unstage action passed a function where the command factory expects the argument list of a git command. The factory reads the first argument to name the worker thread, so the call raised `TypeError: 'function' object is not subscriptable` and the file was never unstaged. `git reset HEAD -- <path>` unstages the file on its own, and it also works in a repository that has no commit yet: git falls back to the empty tree and the file returns to being untracked. The two step fallback that was there for that case is not needed. A contract test now checks that every background action starts with an argument tuple, so this shape cannot slip through a review again.
The branch list lived behind a popup that the branch name in the header opened. It is now a Branches section in the panel, above the file lists: the branch the project is on, the list of local and remote branches with a filter, and the row that creates a new one. The section opens the first time the panel is shown and folds away like the file lists. The branch list no longer needs a process of its own. The background status pass collects the branches together with the file lists now, so the list is always the one the repository actually has.
Pick a branch in the list and the actions below it apply to that branch: Checkout switches to it, Rename gives it a new name, and Delete removes it. The plain Delete lets git refuse a branch whose commits were never merged; Force delete removes it anyway. The list selects instead of switching now. The branch the project is on cannot be deleted, so the actions need a target of their own. Every background action now takes a job — a callable that runs the command on the worker thread — instead of an argument list. The name a new branch is created with is checked on the worker thread too, so the render thread no longer spawns a process: creating a branch used to run `git check-ref-format` while the frame was being drawn, and the panel used to probe `git --version` when it opened. Whether git is usable at all is now answered by the exit code of the status command.
The Branches section now lists the commits of the selected branch, newest first, with the short hash and the subject of each one. The log is fetched on a worker thread, so a branch with a long history does not stall the frame. Fixes along the way: an empty log no longer starts a git process on every frame, the entries of the previously selected branch are dropped when the selection changes, the log is fetched again after a commit, and the selection follows a branch that was renamed or forgets one that was deleted.
The 0.2.0.1, 0.2.0.2, and 0.2.0.3 builds were stepping stones towards this release. The manifest goes back to 0.2.0 and the changelog becomes a single 0.2.0 section that describes the panel as it ships. The Engine API allowlist in the contract test was checked against the upstream master branch: input_uint and push_id_str are gone upstream, so they were dropped rather than left to let a call to a method that does not exist pass.
The Engine only accepts a plugin package whose version is higher than the one already installed, and a 0.2.0 build was installed locally before the branch work was finished. The release therefore moves to 0.2.1, and the changelog heading follows it.
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.
Summary
The panel now manages branches without leaving the Editor. A Branches section shows the branch the project is on with its upstream and how far it has drifted, and lists the local and the remote branches Git already knows about. Filtering the list runs no command; picking a branch marks it as the target of the actions below the list — Checkout, Rename, Delete, and Force delete — and a row at the bottom creates a branch from the current
HEAD. The selected branch also shows its commit log.Every git command moved to a worker thread, the status format changed to porcelain v2, unstaging works again, and the Console became the one place where a failure survives.
This release also carries the Console error-reporting fix that was planned as a separate patch release. A bugfix on its own is a hotfix, so both land together as 0.2.1.
main(ef823b5, already contains v0.1.5)feat/branch-switch(42529e3)What's changed
Branch management in the panel
git check-ref-format --branchfirst, so a name Git would refuse never reaches the command, and the selection follows the branch to its new name.HEADand switches to it.The commit log of a branch
Every git command moved off the render thread
git init, the branch listing, the branch log, and the checkout — now runs on a worker thread. The render thread only draws the last snapshot it received, so a large repository no longer stalls the Editor and a slow checkout no longer freezes a frame.git --versionprobe, and a branch name is validated on the worker thread instead of while the frame is being drawn.package/editor/wokrlie/git_integration/git.py. That module never touches the Engine API, which is what makes it safe to call from a worker thread.Unstaging works again
TypeError: 'function' object is not subscriptableand the file was never unstaged.git reset HEAD -- <path>unstages the file on its own, and it also works in a repository that has no commit yet: git falls back to the empty tree and the file returns to being untracked. The two-step fallback that was there for that case is not needed.The status format changed
git status --porcelain=v2 -z --branchreplaces the v1 porcelain format. One call returns the branch name, the upstream, the ahead/behind counters, and the file list together.-zkeeps a path that is not plain ASCII literal. The v1 format quoted it as an octal escape, so a file called文档/说明.mdappeared as"\346\226\207..."— that is fixed.A failure dialog that points at the Console
Debug.log_error(...)and tagged with the plugin's source, so the Engine can group and clear the plugin's entries on their own. The entry quotes the command line, the exit code, and Git's own message, so the failure can be reproduced by hand.The Console reporting fix that came with it
Debug.error(...), which is not an Engine API — the Engine providesDebug.log_error. The call raisedAttributeErrorbefore the Git message could be logged, so the reason a commit, a stage, orgit initfailed never reached the Console. That has been true since the first implementation (v0.1.3, commit72c2527).tests/test_engine_api_usage.pyscans the plugin sources and fails on anyDebug.*orctx.*method the Engine does not provide.Debug.errorlooks perfectly reasonable in a review, and no human reliably catches that; the test does.Root cause of the reporting bug
The Engine's
Debugclass exposeslog,log_warning,log_error,log_exception,log_suppressed,log_assert,clear_console,log_internal,log_debugand thereport_*family. There is noerror, and the module-level aliases are onlylog,log_warning,log_errorandlog_exception.icons.pyused the correctDebug.log_suppressed(...)throughout, which is why only the panel's error paths were affected.Requirements
Git 2.13 or newer.
git status --porcelain=v2needs Git 2.11, and the%(upstream:short)field ofgit for-each-refneeds Git 2.13. Both are from 2016 and 2017.Commits
d133d41—fix: report Git failures in the Console instead of raising AttributeError40d6a4b—feat: switch and create branches from the panel2757bef—docs: describe the branch workflow and the version the panel needs147eaab—chore: prepare the 0.2.0 releaseef1d751—fix: unstage a file with one git command1f0ed15—feat: move the branches into their own sectionee69216—feat: delete and rename branches from the panele9f9fa0—feat: show the commit log of the selected branchb33d6d9—chore: fold the development versions back into 0.2.042529e3—chore: raise the release version to 0.2.1The middle commits are the development steps towards this release: the branch list moved into its own section, the select-and-act model replaced switch-on-click, rename and delete arrived, and the branch log came last.
b33d6d9folds them back into a single version and a single changelog section, so nothing from that work has to ship as a separate patch release; it also drops two context methods from the contract test's allowlist that the Engine no longer declares, so a call to a method that does not exist cannot slip past the test.42529e3raises the version to 0.2.1, because the Engine only accepts a package whose version is higher than the one already installed.