-
Notifications
You must be signed in to change notification settings - Fork 18
/
sync.sh
executable file
·43 lines (36 loc) · 1.07 KB
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# Usage: sync.sh <path/to/filtered>
set -eu
root=$(pwd)
mkdir -p "$1"
cd -- "$1"
filtered=$(pwd)
mkdir -p "$root/_cache"
cd "$root/_cache"
export PATH="$PWD:$PATH"
step() {
if [ "${TERM-}" != '' ]; then
tput setaf 12
fi
>&2 printf '* %s\n' "$*"
if [ "${TERM-}" != '' ]; then
tput sgr0
fi
}
step Downloading git-filter-repo if needed
if ! git filter-repo --version 2> /dev/null; then
curl -O https://raw.githubusercontent.com/newren/git-filter-repo/v2.38.0/git-filter-repo
chmod +x git-filter-repo
git filter-repo --version
fi
step Cloning upstream if needed
if ! [ -e upstream ]; then
git clone --bare --single-branch --progress https://github.com/mozilla/gecko-dev.git upstream
fi
step Updating upstream
branch=$(git -C upstream rev-parse --abbrev-ref HEAD)
git -C upstream fetch origin $branch:$branch
step Filtering upstream
# Cloning and filtering is much faster than git filter-repo --source --target.
git clone --bare upstream -- "$filtered"
git -C "$filtered" filter-repo --force --paths-from-file "$root/style.paths"