Guest User

Untitled

a guest
Jul 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. . $(dirname $0)/adc.common-functions
  4.  
  5. [ $# -eq 2 ] || die "usage: $0 <repo> <branch>"
  6.  
  7. if [ $SDB_WRITER_ALLOWED ]; then
  8. # this will check only for write permission on the given repository
  9. get_rights_and_owner $1 # this also set $repo variable
  10. [ -z "$perm_write" ] && die "You don't have write permission on $repo"
  11. else
  12. # require a repository creator to change default branch
  13. valid_owned_repo $1
  14. fi
  15.  
  16. # move to repo dir
  17. cd "$GL_REPO_BASE_ABS/$repo.git"
  18.  
  19. # check for branch existence
  20. match=`git branch | sed 's/^( |*) //' | grep $2`
  21. # this will check for an exact match in branch name
  22. [ "$2" = "$match" ] || die "Unable to find branch $2 in repository $repo"
  23.  
  24. # update the default checked out branch
  25. git symbolic-ref HEAD refs/heads/$match
  26.  
  27. echo "Head branch for repository $1 updated to $2"
Add Comment
Please, Sign In to add comment