mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +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>
		
			
				
	
	
		
			28 lines
		
	
	
		
			682 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			682 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env bash
 | 
						|
set -e
 | 
						|
 | 
						|
if ! git diff-index --quiet HEAD; then
 | 
						|
    set +x
 | 
						|
    echo "There are uncommitted changes:"
 | 
						|
    git status --short
 | 
						|
    echo "Doing nothing to avoid losing your work."
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
remote_default="$(git config zulip.zulipRemote || echo upstream)"
 | 
						|
pseudo_remote="$(git config zulip.prPseudoRemote || echo)"
 | 
						|
 | 
						|
request_id="$1"
 | 
						|
remote=${2:-"$remote_default"}
 | 
						|
 | 
						|
if [ -z "$pseudo_remote" ]; then
 | 
						|
    set -x
 | 
						|
    git fetch "$remote" "pull/$request_id/head"
 | 
						|
    git reset --hard FETCH_HEAD
 | 
						|
else
 | 
						|
    target_ref=refs/remotes/"$pseudo_remote"/"$request_id"
 | 
						|
    set -x
 | 
						|
    git fetch "$remote" +"pull/$request_id/head:$target_ref"
 | 
						|
    git reset --hard "$target_ref"
 | 
						|
fi
 |