mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 05:23:35 +00:00 
			
		
		
		
	/bin/sh and /usr/bin/env are the only two binaries that NixOS provides at a fixed path (outside a buildFHSUserEnv sandbox). This discussion was split from #11004. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
		
			
				
	
	
		
			39 lines
		
	
	
		
			971 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			971 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
 | 
						|
function error_out {
 | 
						|
    echo -en '\e[0;31m'
 | 
						|
    echo "$1"
 | 
						|
    echo -en '\e[0m'
 | 
						|
    exit 1
 | 
						|
}
 | 
						|
 | 
						|
status=$(git status --porcelain | grep -v '^??')
 | 
						|
[ -n "$status" ] && error_out "Working directory or index not clean"
 | 
						|
 | 
						|
old_ref=$(git rev-list --max-count=1 HEAD)
 | 
						|
branch=$1
 | 
						|
branch_ref=$(git rev-list --max-count=1 "$branch") || error_out "Unknown branch: $branch"
 | 
						|
 | 
						|
if [ "$old_ref" == "$branch_ref" ]; then
 | 
						|
    new_ref=master
 | 
						|
else
 | 
						|
    if ref_name=$(git describe --all --exact "$old_ref"); then
 | 
						|
        new_ref=$(echo "$ref_name" | perl -pe 's{^(heads|remotes)/}{}')
 | 
						|
    else
 | 
						|
        new_ref=$old_ref
 | 
						|
    fi
 | 
						|
fi
 | 
						|
 | 
						|
[ -z "$branch" ] && error_out "You must specify a branch name to deploy"
 | 
						|
 | 
						|
git fetch -p
 | 
						|
 | 
						|
git rebase origin/master "$branch" || error_out "Rebase onto origin/master failed"
 | 
						|
 | 
						|
git push . HEAD:master
 | 
						|
git push origin master || error_out "Push of master to origin/master failed"
 | 
						|
 | 
						|
git checkout "$new_ref"
 | 
						|
git branch -D "$branch"
 | 
						|
git push origin ":$branch"
 |