mirror of
https://github.com/chenasraf/git-open.git
synced 2026-05-18 01:38:59 +00:00
fix: open file from subdirectory using GIT_PREFIX var
This commit is contained in:
@@ -121,7 +121,7 @@ git_open_file() {
|
||||
fi
|
||||
|
||||
repo_path=$(git_get_repo_path $remote)
|
||||
prefix=$(git rev-parse --show-prefix 2>/dev/null)
|
||||
prefix=${GIT_PREFIX:-$(git rev-parse --show-prefix 2>/dev/null)}
|
||||
file=$([[ -n "$2" ]] && echo "${prefix}$2" || echo "")
|
||||
branch=$([[ -n "$3" ]] && echo "$3" || git branch --show-current)
|
||||
|
||||
|
||||
@@ -71,6 +71,9 @@ assert_value "https://github.com/chenasraf/git-open/blob/develop/test.zsh" $(git
|
||||
describe "git_open_file from subdirectory"
|
||||
assert_value "https://github.com/chenasraf/git-open/blob/$current_branch/tests/test.zsh" $(cd "${0:A:h}" && git_open_file "" test.zsh)
|
||||
|
||||
describe "git_open_file from subdirectory (via git alias)"
|
||||
assert_value "https://github.com/chenasraf/git-open/blob/$current_branch/tests/test.zsh" $(GIT_PREFIX=tests/ git_open_file "" test.zsh)
|
||||
|
||||
describe "git_open_commit"
|
||||
assert_value "https://github.com/chenasraf/git-open/commit/1a4c2b6" $(git_open_commit "" 1a4c2b6)
|
||||
assert_value "https://github.com/chenasraf/git-open/commit/$current_ref" $(git_open_commit)
|
||||
|
||||
Reference in New Issue
Block a user