-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(picker.git_branches): handle detached HEAD #671
Merged
Merged
Conversation
This file contains 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
ty! |
@folke Found another edge case: $ git checkout v2.14.0
$ git --no-pager branch --no-color -vvl
* (HEAD detached at v2.14.0) 8d820a6 chore(main): release 2.14.0 (#646)
main 233356e [origin/main] chore(build): auto-generate docs
Can be fixed by extending the diff --git a/lua/snacks/picker/source/git.lua b/lua/snacks/picker/source/git.lua
index 4f489ea..d05fec7 100644
--- a/lua/snacks/picker/source/git.lua
+++ b/lua/snacks/picker/source/git.lua
@@ -164,11 +164,12 @@ function M.branches(opts)
local cwd = vim.fs.normalize(opts and opts.cwd or uv.cwd() or ".") or nil
cwd = Snacks.git.get_root(cwd)
+ local pattern_detached_at = "[a-zA-Z0-9.v]+" -- tag or commit hash
local pattern_hash = "[a-zA-Z0-9]+"
local patterns = {
-- stylua: ignore start
--- e.g. "* (HEAD detached at f65a2c8) f65a2c8 chore(build): auto-generate docs"
- "^(.)%s(%(HEAD detached at " .. pattern_hash .. "%))%s+(" .. pattern_hash .. ")%s*(.*)$",
+ "^(.)%s(%(HEAD detached at " .. pattern_detached_at .. "%))%s+(" .. pattern_hash .. ")%s*(.*)$",
--- e.g. " main d2b2b7b [origin/main: behind 276] chore(build): auto-generate docs"
"^(.)%s(%S+)%s+(".. pattern_hash .. ")%s*(.*)$",
-- stylua: ignore end However, |
folke
added a commit
that referenced
this pull request
Jan 21, 2025
Changed it so it can parse all special states |
folke
pushed a commit
that referenced
this pull request
Jan 23, 2025
🤖 I have created a release *beep* *boop* --- ## [2.15.0](v2.14.0...v2.15.0) (2025-01-23) ### Features * **debug:** truncate inspect to 2000 lines max ([570d219](570d219)) * **input:** input history. Closes [#591](#591) ([80db91f](80db91f)) * **input:** persistent history. Closes [#591](#591) ([0ed68bd](0ed68bd)) * **picker.debug:** more info about potential leaks ([8d9677f](8d9677f)) * **picker.filter:** Filter arg for filter ([5a4b684](5a4b684)) * **picker.finder:** optional transform function ([5e69fb8](5e69fb8)) * **picker.format:** `filename_only` option ([0396bdf](0396bdf)) * **picker.git:** git_log, git_log_file, git_log_line now do git_checkout as confirm. Closes [#722](#722) ([e6fb538](e6fb538)) * **picker.help:** add more color to help tags ([5778234](5778234)) * **picker.keymaps:** add global + buffer toggles ([#705](#705)) ([b7c08df](b7c08df)) * **picker.keymaps:** improvements to keymaps picker ([2762c37](2762c37)) * **picker.matcher:** frecency and cwd bonus can now be enabled on any picker ([7b85dfc](7b85dfc)) * **picker.multi:** multi now also merges keymaps ([8b2c78a](8b2c78a)) * **picker.preview:** better positioning of preview location ([3864955](3864955)) * **picker.preview:** fallback highlight of results when no `end_pos`. Mostly useful for grep. ([d12e454](d12e454)) * **picker.smart:** add bufdelete actions from buffers picker ([#679](#679)) ([67fbab1](67fbab1)) * **picker.smart:** re-implemented smart as multi-source picker ([450d1d4](450d1d4)) * **picker.util:** smart path truncate. Defaults to 40. Closes [#708](#708) ([bab8243](bab8243)) * **picker:** added `lazy` source to search for a plugin spec. Closes [#680](#680) ([d03bd00](d03bd00)) * **picker:** added `opts.rtp` (bool) to find/grep over files in the rtp. See [#680](#680) ([9d5d3bd](9d5d3bd)) * **picker:** added new `icons` picker for nerd fonts and emoji. Closes [#703](#703) ([97898e9](97898e9)) * **picker:** getters and setters for cwd ([2c2ff4c](2c2ff4c)) * **picker:** multi source picker. Combine multiple pickers (as opposed to just finders) in one picker ([9434986](9434986)) * **picker:** persistent history. Closes [#528](#528) ([ea665eb](ea665eb)) * **picker:** preview window horizontal scrolling ([#686](#686)) ([bc47e0b](bc47e0b)) * **picker:** syntax highlighting for command and search history ([efb6d1f](efb6d1f)) * **profiler:** added support for `Snacks.profiler` and dropped support for fzf-lua / telescope. Closes [#695](#695) ([ada83de](ada83de)) ### Bug Fixes * **picker.actions:** `checktime` after `git_checkout` ([b86d90e](b86d90e)) * **picker.async:** better handling of abort and schedule/defer util function ([dfcf27e](dfcf27e)) * **picker.async:** fixed aborting a coroutine from the coroutine itself. See [#665](https://github.com/folke/snacks.nvim/issues/665) ([c1e2c61](c1e2c61)) * **picker.files:** include symlinks ([dc9c6fb](dc9c6fb)) * **picker.frecency:** track visit on BufWinEnter instead of BufReadPost and exclude floating windows ([024a448](024a448)) * **picker.git_branches:** handle detached HEAD ([#671](#671)) ([390f687](390f687)) * **picker.git:** `--follow` only works for `git_log_file`. Closes [#666](#666) ([23a8668](23a8668)) * **picker.git:** parse all detached states. See [#671](#671) ([2cac667](2cac667)) * **picker.grep:** off-by-one for grep results col ([e3455ef](e3455ef)) * **picker.icons:** bump build for nerd fonts ([ba108e2](ba108e2)) * **picker.icons:** fix typo in Nerd Fonts and display the full category name ([#716](#716)) ([a4b0a85](a4b0a85)) * **picker.icons:** opts.icons -> opts.icon_sources. Fixes [#715](#715) ([9e7bfc0](9e7bfc0)) * **picker.input:** better handling of `stopinsert` with prompt buffers. Closes [#723](#723) ([c2916cb](c2916cb)) * **picker.input:** correct cursor position in input when cycling / focus. Fixes [#688](#688) ([93cca7a](93cca7a)) * **picker.lsp:** include_current on Windows. Closes [#678](#678) ([66d2854](66d2854)) * **picker.lsp:** make `lsp_symbols` work for unloaded buffers ([9db49b7](9db49b7)) * **picker.lsp:** schedule_wrap cancel functions and resume when no clients ([6cbca8a](6cbca8a)) * **picker.lsp:** use async from ctx ([b878caa](b878caa)) * **picker.lsp:** use correct buf/win ([8006caa](8006caa)) * **picker.preview:** clear buftype for file previews ([5429dff](5429dff)) * **picker.undo:** use new API. Closes [#707](#707) ([79a6eab](79a6eab)) * **picker.util:** for `--` args require a space before ([ee6f21b](ee6f21b)) * **picker.util:** more relaxed resolve_loc ([964beb1](964beb1)) * **picker.util:** prevent empty shortened paths if it's the cwd. Fixes [#721](#721) ([14f16ce](14f16ce)) * **picker:** better handling of buffers with custom URIs. Fixes [#677](#677) ([cd5eddb](cd5eddb)) * **picker:** don't jump to invalid positions. Fixes [#712](#712) ([51adb67](51adb67)) * **picker:** don't try showing the preview when the picker is closed. Fixes [#714](#714) ([11c0761](11c0761)) * **picker:** resume. Closes [#709](#709) ([9b55a90](9b55a90)) * **picker:** starting a picker from the picker sometimes didnt start in insert mode. Fixes [#718](#718) ([08d4f14](08d4f14)) * **picker:** update title on find. Fixes [#717](#717) ([431a24e](431a24e)) * **scroll:** handle buffer changes while animating ([3da0b0e](3da0b0e)) * **win:** better way of finding a main window when fixbuf is `true` ([84ee7dd](84ee7dd)) * **zen:** parent buf. Fixes [#720](#720) ([f314676](f314676)) ### Performance Improvements * **picker.frecency:** cache all deadlines on load ([5b3625b](5b3625b)) * **picker:** gc optims ([3fa2ea3](3fa2ea3)) * **picker:** small optims ([ee76e9b](ee76e9b)) * **picker:** small optims for abort ([317a209](317a209)) * **picker:** use picker ref in progress updater. Fixes [#710](#710) ([37f3888](37f3888)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Description
Handle detached HEAD
Related Issue(s)
Screenshots
Before:

After:
