Last active
January 31, 2021 12:28
-
-
Save bowmanjd/cd284d8da97d7d254da2c71c9761eba8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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**. | |
# | |
# Set-ExecutionPolicy RemoteSigned -scope CurrentUser | |
# iwr -useb https://gist.github.com/bowmanjd/cd284d8da97d7d254da2c71c9761eba8/raw | iex | |
# | |
# You may read a brief synopsis at | |
# https://dev.to/bowmanjd/get-github-default-branch-from-the-command-line-powershell-or-bash-zsh-37m9 | |
function gldefbranch { | |
Param ([string]$repo) | |
$repo = $repo.replace("/","%2F") | |
$branch = (iwr -useb "https://gitlab.com/api/v4/projects/$repo" | ConvertFrom-Json | select -exp default_branch) | |
if ($branch) { | |
echo $branch | |
} else { | |
echo "master" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment