Skip to content

Instantly share code, notes, and snippets.

@bowmanjd
Created January 30, 2021 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bowmanjd/33c34f105302288e667d3105efea297a to your computer and use it in GitHub Desktop.
Save bowmanjd/33c34f105302288e667d3105efea297a to your computer and use it in GitHub Desktop.
#!/bin/sh
# Copyright 2021 Jonathan Bowman. All documentation and code contained
# in this file may be freely shared in compliance with the
# Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# and is **provided "AS IS" without warranties or conditions of any kind**.
#
# OUT="$(mktemp)"; wget -q -O - https://gist.github.com/bowmanjd/d72e2e89996087f71ffe3e9777dea5a2/raw > $OUT; . $OUT
#
# You may read a brief synopsis at
# https://dev.to/bowmanjd/get-github-default-branch-from-the-command-line-powershell-or-bash-zsh-37m9
defbranch () {
REPO=$(echo $1 | sed "s/\//%2F/g")
wget -q -O - "https://gitlab.com/api/v4/projects/$REPO" | sed -nE 's/.*"default_branch":"([^"]+).*/\1/p'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment