mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 07:16:23 -04:00
Refactor: Replace _forgit_extract_sha variable with function
We used to store code that extracts the commit hash from a line in a variable. This commit replaces this variable with a function.
This commit is contained in:
parent
67d6d8508f
commit
0b7f1f47f5
|
|
@ -75,7 +75,6 @@ _forgit_emojify() {
|
|||
}
|
||||
|
||||
# extract the first git sha occurring in the input and strip trailing newline
|
||||
_forgit_extract_sha="grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]'"
|
||||
_forgit_extract_sha() {
|
||||
grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]'
|
||||
}
|
||||
|
|
@ -556,7 +555,7 @@ _forgit_rebase() {
|
|||
git log "${graph[@]}" --color=always --format="$_forgit_log_format" "$@" |
|
||||
_forgit_emojify |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||
eval "$_forgit_extract_sha")
|
||||
_forgit_extract_sha)
|
||||
if [[ -n "$target_commit" ]]; then
|
||||
prev_commit=$(_forgit_previous_commit "$target_commit")
|
||||
git rebase -i "${_forgit_rebase_git_opts[@]}" "$prev_commit"
|
||||
|
|
@ -590,7 +589,7 @@ _forgit_fixup() {
|
|||
git log "${graph[@]}" --color=always --format="$_forgit_log_format" "$@" |
|
||||
_forgit_emojify |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||
eval "$_forgit_extract_sha")
|
||||
_forgit_extract_sha)
|
||||
if [[ -n "$target_commit" ]] && git commit "${_forgit_fixup_git_opts[@]}" --fixup "$target_commit"; then
|
||||
prev_commit=$(_forgit_previous_commit "$target_commit")
|
||||
# rebase will fail if there are unstaged changes so --autostash is needed to temporarily stash them
|
||||
|
|
@ -719,7 +718,7 @@ _forgit_checkout_commit() {
|
|||
[[ $_forgit_log_graph_enable == true ]] && graph=(--graph)
|
||||
commit="$(git log "${graph[@]}" --color=always --format="$_forgit_log_format" |
|
||||
_forgit_emojify |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf | eval "$_forgit_extract_sha")"
|
||||
FZF_DEFAULT_OPTS="$opts" fzf | _forgit_extract_sha)"
|
||||
_forgit_git_checkout_commit "$commit"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue