Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bin/git-browse
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ fi
commit_hash=$(git rev-parse HEAD 2>/dev/null)
commit_or_branch=${commit_hash:-${branch}}

# Check that the commit branch actually *exists* on the remote first:
if ! git branch --remotes --contains "${commit_or_branch}" 2>/dev/null |
grep -q "\<${remote}\>/"
then
echo "Commit not yet pushed to remote '${remote}'"
exit 1
fi

if [[ $remote_url =~ gitlab ]]; then
# construct gitlab urls
# https://gitlab.com/<user_or_group>/<repo>/-/blob/<commit_or_branch>/<filename>#L<line1>-<line2>
Expand Down
Loading