Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 57d3d85

Browse files
committed
Add repo merge script
1 parent f331ff6 commit 57d3d85

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

merge-repos.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# create tmp folder
6+
WORK_DIR=`mktemp -d`
7+
8+
function cleanup {
9+
rm -rf "$WORK_DIR"
10+
echo "Deleted temp working directory $WORK_DIR"
11+
}
12+
13+
trap cleanup EXIT
14+
15+
git clone [email protected]:grafana/pyroscope.git "${WORK_DIR}/og"
16+
git clone [email protected]:grafana/phlare.git "${WORK_DIR}/phlare"
17+
18+
19+
# rewrite phlare history to maintain correct links
20+
cd "$WORK_DIR/phlare"
21+
git filter-repo --message-callback '
22+
import re
23+
return re.sub(b"#([0-9]+)", b"https://github.com/grafana/phlare/issues/\\1", message)
24+
'
25+
26+
# move import path to new repo's
27+
git ls-files '*.go' go.mod go.sum | xargs sed -i 's#github.com/grafana/phlare#github.com/grafana/pyroscope#g'
28+
go mod tidy
29+
git add -A .
30+
git commit -m "Rename go import path"
31+
32+
# move og into subfolder
33+
cd "$WORK_DIR/og"
34+
mkdir -p ../temp
35+
mv * ../temp
36+
mv .* ../temp
37+
mv ../temp/.git .
38+
mv ../temp og/
39+
git add -A .
40+
git commit -m "Move og-pyroscope into subfolder"
41+
42+
# now merge phlare in
43+
git remote add phlare "${WORK_DIR}/phlare"
44+
git fetch phlare
45+
git merge phlare/main --allow-unrelated-histories -m "The new Pyroscope"
46+
47+
git push [email protected]:simonswine/pyroscope HEAD:merged -f

0 commit comments

Comments
 (0)