mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
12beb018dd
--HG-- extra : rebase_source : 6afc6f20c26a9a32afa42c6b47f2775ca7fd91a3
33 lines
649 B
Bash
Executable File
33 lines
649 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
if [ $# -lt 3 ]; then
|
|
echo "Usage: $0 <repo> <branch> <directory>" 1>&2
|
|
exit 2
|
|
fi
|
|
|
|
REPO=$1
|
|
COMMIT=$2
|
|
DIR=$3
|
|
|
|
echo "Copy '$COMMIT' from '$REPO' to '$DIR'"
|
|
if [ -f $DIR/.git-copy ]; then
|
|
CURRENT=$(cat $DIR/.git-copy)
|
|
if [ $(echo -n $COMMIT | wc -c) != "40" ]; then
|
|
ACTUAL=$(git ls-remote $REPO $COMMIT | cut -c 1-40 -)
|
|
else
|
|
ACTUAL=$COMMIT
|
|
fi
|
|
if [ CURRENT = ACTUAL ]; then
|
|
echo "Up to date."
|
|
fi
|
|
fi
|
|
|
|
mkdir -p $DIR
|
|
git -C $DIR init -q
|
|
git -C $DIR fetch -q --depth=1 $REPO $COMMIT:git-copy-tmp
|
|
git -C $DIR reset --hard git-copy-tmp
|
|
git -C $DIR show-ref HEAD | cut -c 1-40 - > $DIR/.git-copy
|
|
rm -rf $DIR/.git
|