Skip to content

Commit 443ebeb

Browse files
committed
fix: open file from subdirectory using GIT_PREFIX var
1 parent e185d99 commit 443ebeb

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

git-open.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ git_open_file() {
121121
fi
122122

123123
repo_path=$(git_get_repo_path $remote)
124-
prefix=$(git rev-parse --show-prefix 2>/dev/null)
124+
prefix=${GIT_PREFIX:-$(git rev-parse --show-prefix 2>/dev/null)}
125125
file=$([[ -n "$2" ]] && echo "${prefix}$2" || echo "")
126126
branch=$([[ -n "$3" ]] && echo "$3" || git branch --show-current)
127127

tests/test.zsh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ assert_value "https://github.com/chenasraf/git-open/blob/develop/test.zsh" $(git
7171
describe "git_open_file from subdirectory"
7272
assert_value "https://github.com/chenasraf/git-open/blob/$current_branch/tests/test.zsh" $(cd "${0:A:h}" && git_open_file "" test.zsh)
7373

74+
describe "git_open_file from subdirectory (via git alias)"
75+
assert_value "https://github.com/chenasraf/git-open/blob/$current_branch/tests/test.zsh" $(GIT_PREFIX=tests/ git_open_file "" test.zsh)
76+
7477
describe "git_open_commit"
7578
assert_value "https://github.com/chenasraf/git-open/commit/1a4c2b6" $(git_open_commit "" 1a4c2b6)
7679
assert_value "https://github.com/chenasraf/git-open/commit/$current_ref" $(git_open_commit)

0 commit comments

Comments
 (0)