Commit graph

493 commits

Author SHA1 Message Date
Chris Apple 2436fc4e11
Fix issue where diff preview was broken on mac (#365)
Closes #362
2024-03-14 06:55:17 -07:00
Chris Apple 86dfdf89da
Delete brew workflow (#360) 2024-03-06 08:05:15 -08:00
Hoang Nguyen 038cce2b3b
feat(fish): use abbr instead of alias (#348)
Switch from aliases to abbreviations, as I suggested in

    feat(completions): add completion for fish #344 (comment)
    string collect returns 1 on empty argument, so it's used here to avoid repeating if else end blocks. Another benefit is that the output of string collect is ensured to be a single string. From string --help:

    string collect collects its input into a single output argument, without splitting the output when used in a command substitution. This is useful when trying to collect multiline output from another
    command into a variable. Exit status: 0 if any output argument is non-empty, or 1 otherwise.

This PR is marked as breaking change, since abbr behaves differently from alias. It can only be used in the interactive command line (so putting exec glo into your scripts won't work).
2024-03-05 10:56:51 -08:00
Chris Apple 7439d546c3
Fix homebrew update action to run on tag push (#356) 2024-03-01 06:38:56 -08:00
sandr01d 07f7e4350b
Fix diff preview and edit for files with a ']' character in their name (#354)
Our sed command for removing the short status (e.g. [M]) from gits
output to extract the file name with _forgit_diff matched until the
last ']' character in the line due to sed being greedy. This created
issues with file names that contain a ']' character.
To fix this, I made sure that only the short status is removed by sed,
independently of the file name.
2024-02-28 21:01:56 +01:00
Raphael Boidol 0cce34ef51
chore(gha): Update actions/checkout from v3 to v4 (#351)
Resolve deprecation warnings for GitHub actions, see https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-02-13 09:54:39 -08:00
Chris Apple 00ed721ece
Consolidate zsh completions in one file (#340)
Moved the completion definitions for zsh that previously were in completions/git-forgit.zsh and had to be sourced manually on shell startup into completions/_git-forgit, where they are automatically handled by compinit on shell startup. Sourcing a file to get completions is no longer necessary for zsh users.
If you're having issues after updating, and completions for commands such as `forgit::add` or aliases like `ga` aren't working, remove your completions cache (~/.zcompdump) and restart your shell.
Simplified _git-forgit to allow it to be called from within the completion script on the first run of a session.

---------

Co-authored-by: sandr01d <88739791+sandr01d@users.noreply.github.com>
2024-02-09 22:17:22 +01:00
Hoang Nguyen 2b58a2e6a7
fix(fish): clean up variables (#350)
* use `status dirname` builtin to save 1 dirname call
* use builtin test function instead of [ command
* use local scoping for INSTALL_DIR variable (and make it lowercase to
  indicate such change)

Ref: https://fishshell.com/docs/current/cmds/test.html
2024-02-06 20:26:53 -08:00
Hoang Nguyen cf447a64aa
feat(completions): add completion for fish (#344)
fish's builtin git completion automatically registers git-forgit completions as completions for forgit subcommand of git. Therefore this PR provides completions for both formats git-forgit and git forgit.

Simple subcommands get the completion list from __fish_git_* functions, while others requiring more than 1 __fish_git_* completion sources reuse the completion items from the corresponding git commands.
2024-02-06 09:27:44 -08:00
Wenxuan 714f6dfec1
fix: avoid polluting the global namespace (#347)
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
2024-02-06 14:21:51 +08:00
Hoang Nguyen 2eda2a457a
fix: keep the script compatible with Busybox applets (#345)
Use short flags for sort command
    Remove -n flag for nl command. The numbers in the selection list won't be aligned anymore, but no information is lost.

The current arguments are only presented in GNU's coreutils.
2024-02-05 21:17:16 -08:00
Chris Apple 63fd2ba998
Add new workflow to update homebrew formula on release (#342) 2024-02-02 13:54:42 -08:00
Chris Apple ab7400ddb3
README: Add more explicit instructions for brew, fix headers for AUR, Fig (#339)
Added more explicit instructions, now that I know how our brew installation process works.

While I was there, I moved AUR and Fig to be subheaders of Installation
2024-01-30 06:43:52 -08:00
Chris Apple c663dc1764
README tweak: decrease level of headers (#337) 2024-01-29 10:49:11 -08:00
Edwin Kofler d7f88d75b6
Remove extraneous PATH export (#329) 2023-12-20 06:50:44 -08:00
sandr01d 48e91dadb5
Fixed opening files in the editor when a path contains spaces or a file was renamed (#323)
Fixed two issues that occurred when trying to open files in the editor (ctrl+e). In both cases the wrong files were opened.

1. Files that have spaces in their path. I fixed this by properly escaping the variables used in _forgit_diff() and forgit_add().
2. When a tracked file was renamed and added, trying to open it in the editor from the diff view, would open a file with a name that consists of both, the old and the new name. I added a separate sed command that can handle this special case.
2023-08-27 17:06:30 +02:00
Tim e8e308340a
checkout_branch: support "-" argument (#322)
git natively supports `-` as an argument to `git switch` and `git
checkout`. It is shorthand for `@{-1}`, which is a way to refer to the
last branch you were on.

forgit used to interpret `-` as a branch name, detect that it does not
exist yet and create a new one with this name, which does not work.

Add a check whether `-` is passed on the command line and do not create
a new branch in this case
2023-08-13 08:15:19 +02:00
sandr01d b663d22f5b
Trigger AUR action on workflow_run instead of release (#320)
Turns out that GitHub actions do not trigger other actions by default. Using workflow_run instead of release as a trigger should solve this.
2023-08-06 17:00:10 +02:00
sandr01d 6cbbe1805a
Removed the note about using forgit as a git subcommand from the 'tips' section (#321)
The note was redundant because it is explained in more detail in the 'git integration' section.
2023-08-06 16:52:49 +02:00
sandr01d 9b5714fcde
Do not hide error messages when trying to return early (#318)
Most of forgits functions allow to invoke git directly when arguments were passed. In most of these functions we only return early when the git command that is executed returns successfully. This hides error messages from the user. As discussed with @carlfriedrich in #316, I've modified this behavior to also return early when the git command was not successful, so we're transparent about gits error messages and return values. This also fixes an infinite loop printing an error message when invalid arguments were passed to gsp. Because gbl and gclean allow passing arguments to the git command that is invoked when we don't return early, I've modified their behavior to only invoke git directly (and return early) in the case that non flag arguments were passed.
I've also modified gclean to use the -q flag instead of piping it's output to /dev/null.
2023-08-06 16:50:25 +02:00
Michael Bianco f1ac9e3f7f
docs: example of using config vars to sort git branch (#319) 2023-07-12 10:59:30 -07:00
sandr01d 8547b554c8
Make gclean parameters consistent (#317) 2023-07-06 20:13:03 +02:00
sandr01d 500808d73b
Add AUR release action (#315) 2023-07-04 10:06:00 +08:00
Wenxuan c78c10a028
feat: add a keybind to open current file in editor (#313)
* feat: add a keybind to open current file in default editor

---------

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Co-authored-by: sandr01d <88739791+sandr01d@users.noreply.github.com>
2023-06-19 09:26:07 +08:00
sandr01d ec1bd21468
Added completions for zsh (#310) 2023-06-13 21:55:50 +02:00
sandr01d 665e3fd215
Allow passing parameters to branch_delete and stash_show (#312) 2023-05-31 22:08:57 +02:00
sandr01d 0bedb80c1f
Allow passing parameters to forgit::reset::head (#309) 2023-05-31 21:18:13 +02:00
Tom 99cda3248c
Restore support for appending FORGIT_INSTALL_DIR to path (#308)
It seems somewhere along the line FORGIT_INSTALL_DIR stopped getting exported. According to the README you can append it to your path to get access to git forgit ... commands however this seems to no longer work - this is an attempt to restore this functionality.
2023-05-16 08:45:52 -07:00
Tom f73ae9754e
Allow configuration of checkout_branch branch cmd (#307) 2023-05-16 08:45:18 -07:00
Tim 5642a1a730
Use correct IFS store/restore mechanism (#306)
The previous implementation had the problem that if IFS was not set
before, it was set to an empty string after restoring, which is not the
same as being unset. This broke grc / git forgit revert_commit, since
"git revert" was being interpreted as the command name instead of
command and argument.

The correct way is to check whether IFS is unset and, if so, unset it
again afterwards.

See for reference:
https://unix.stackexchange.com/a/264947/317320
2023-05-08 09:51:13 -07:00
Tim f74aa93232
Fix grc / forgit revert_commit (#305)
This was accidentally broken since 450615d4 due to a wrong git call.
2023-05-07 11:53:19 +02:00
Patrick Linnane e8ad636ab0
README: add brew instructions (#302) 2023-05-04 08:38:26 +02:00
Tim adf4e7feb9
Fix wrong documentation of tab toggle direction (#299)
See https://github.com/junegunn/fzf/issues/3256 for reference.

Fixes #298
2023-04-26 13:15:33 +02:00
Tim 3f00348d5c
Add keybinding ctrl+y for copying stash ID in gss (#295) 2023-03-18 16:35:18 +01:00
Tim 2b0cf3c4af
Fix temporary IFS settings (#297)
When setting the IFS for a certain command only, the command must not be
an assignment, otherwise both assignments are evaluated permanently
(see https://unix.stackexchange.com/a/458901/317320).
2023-03-18 16:34:24 +01:00
Tim 450615d48f
Fix git options (#296)
Adding options to a command in a quoted variable as introduced in #292
causes problems in several cases unfortunately (e.g. git rebase
interpreting an empty string argument as a remote, which leads to an
error "unknown upstream ''").

Change the implementation in a way that each git command is stored in a
shell variable, including the options, which is then evaluated.
This also makes the code more DRY because each git options variable is
evaluated only once.

Furthermore, fix temporary IFS settings. When setting the IFS for a
certain command only, the command must not be an assignment, otherwise
both assignments are evaluated permanently
(see https://unix.stackexchange.com/a/458901/317320).
2023-03-18 16:18:11 +01:00
Tim 2a2ee36d56
Add git options for each forgit command (#292)
The git behavior within forgit can now be customized with a dedicated
variable for each forgit command, e.g. `FORGIT_ADD_GIT_OPTS` is passed
to the `git add` call within `ga`.

Also renaming `FORGIT_STASH_PUSH_OPTS` to `FORGIT_STASH_PUSH_FZF_OPTS`
and `FORGIT_REVERT_COMMIT_OPTS` to `FORGIT_REVERT_COMMIT_FZF_OPTS`
for consistency.
2023-03-18 12:25:20 +01:00
Tim f32fd305dc
Fix broken cherry picking (#294)
With the changes of #261 and #266 we accidentally broke the return value
of `_forgit_cherry_pick`, which led to the loop in
`_forgit_cherry_pick_from_branch` being terminated in the wrong cases.
Fix this by moving all the post processing after fzf to a later call.

Also simplify the array population using a single line instead of a
loop.

This should also fix #286 ("fatal: bad revision ''").
2023-03-18 12:19:39 +01:00
Tim 4b8234a9ff
Only show available cherry picks in preview (#293)
This is a follow-up to #266, which already switched to showing only
available commits during cherry-picking. This patch does the same for
the branch preview in _forgit_cherry_pick_from_branch.
2023-03-18 12:10:26 +01:00
Anshuman Medhi 9bb53dc455
Detect unexported variables in fish correctly (#290)
Fixes #289
2023-03-16 09:55:52 -07:00
Tim 8012396587
Fix empty diff preview on renames (#282)
This had been fixed before in #189, but obviously the patch broke
support for whitespaces in file names. That was fixed in #204, which
in turn broke support for renames again.

Prepare the list of file names with the null-character \0 as a delimiter,
so that we can use "xargs -0" to read it. This makes renames as well
as filenames with spaces work correctly.
2023-02-28 22:57:51 +01:00
Christian Fratta 065f7841f3
Meta: Include oh-my-zsh install instructions in README (#283) 2023-02-10 10:26:59 +01:00
Tim aa85792ec4
Add bash completions for forgit functions and aliases (#275)
When using forgit via the shell plugin, source 'git-forgit.bash'
explicitly after 'forgit.plugin.zsh' to enable tab completion for forgit
shell functions and aliases.
2023-01-30 17:46:52 +01:00
ZenLian 8502ae2cc5
fix: glo can not match files (#249)
Fixed "glo -- <files>" behavior to show specified files only instead of
showing all changed files.
2023-01-30 17:43:17 +01:00
sandr01d c098bf2fb1
Modify multiple files at once in ga & gcf (#279)
Checkout/Add files in a single command in _forgit_add and _forgit_checkout_file() instead of processing each file individually with xargs. This has the following benefits:

    It's faster
    Prevents git from spamming "Updated 1 path from the index" for each file when checking out files
2023-01-20 11:49:55 -08:00
sandr01d be8c306c18
Add alias gct for forgit::checkout::tag in fish (#278)
Noticed there was another alias missing for fish. This is the last one :)
2023-01-13 14:59:52 -08:00
Chris Apple 98637db1b0
Only show available cherry picks (#266)
Only shows changes that are eligible for cherry-pick to the branch, not every commit. Also adds nice color to the output
2023-01-11 10:50:41 -08:00
Tim 73aea65778
Add bash completions for git-forgit (#235)
When using forgit as a subcommand of git, put 'git-forgit.bash' in one
of the following places and it will be loaded automatically on tab
completion of 'git forgit' or any configured git aliases of it:

- /usr/share/bash-completion/completions
- ~/.local/share/bash-completion/completions
2023-01-11 10:57:16 +01:00
Tim 548af731f0
Fix command list in help output (#274)
'rebase' and 'fixup' were accidentally displayed on the same line.
2023-01-11 10:22:53 +01:00
sandr01d 329523bd0d
Fixed: Untracked files with spaces in the path do not show a preview in 'ga' (#271) 2023-01-11 08:47:40 +01:00