From 6dbeb98d377bfa6792a8f83125f30e0c1170016b Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Fri, 30 Jun 2023 17:52:13 +0100 Subject: [PATCH 1/3] Add repo merge script --- merge-repos.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 merge-repos.sh diff --git a/merge-repos.sh b/merge-repos.sh new file mode 100755 index 000000000..17e593b56 --- /dev/null +++ b/merge-repos.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# create tmp folder +WORK_DIR=`mktemp -d` + +function cleanup { + rm -rf "$WORK_DIR" + echo "Deleted temp working directory $WORK_DIR" +} + +trap cleanup EXIT + +git clone git@github.com:grafana/pyroscope.git "${WORK_DIR}/og" +git clone git@github.com:grafana/phlare.git "${WORK_DIR}/phlare" + + +# rewrite phlare history to maintain correct links +cd "$WORK_DIR/phlare" +git filter-repo --message-callback ' +import re +return re.sub(b"#([0-9]+)", b"https://github.com/grafana/phlare/issues/\\1", message) +' + +# move import path to new repo's +git ls-files '*.go' go.mod go.sum | xargs sed -i 's#github.com/grafana/phlare#github.com/grafana/pyroscope#g' +go mod tidy +git add -A . +git commit -m "Rename go import path" + +# move og into subfolder +cd "$WORK_DIR/og" +mkdir -p ../temp +mv * ../temp +mv .* ../temp +mv ../temp/.git . +mv ../temp og/ +git add -A . +git commit -m "Move og-pyroscope into subfolder" + +# now merge phlare in +git remote add phlare "${WORK_DIR}/phlare" +git fetch phlare +git merge phlare/main --allow-unrelated-histories -m "The new Pyroscope" + +git push git@github.com:simonswine/pyroscope HEAD:merged -f From e9a91e058bda9046de3cae4e23cb9d31b96a26fa Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Tue, 18 Jul 2023 10:42:07 +0100 Subject: [PATCH 2/3] Also handle forgotten go.mods --- merge-repos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merge-repos.sh b/merge-repos.sh index 17e593b56..e0c719e53 100755 --- a/merge-repos.sh +++ b/merge-repos.sh @@ -24,7 +24,7 @@ return re.sub(b"#([0-9]+)", b"https://github.com/grafana/phlare/issues/\\1", mes ' # move import path to new repo's -git ls-files '*.go' go.mod go.sum | xargs sed -i 's#github.com/grafana/phlare#github.com/grafana/pyroscope#g' +git ls-files '*.go' go.mod go.sum api/go.mod api/go.sum ebpf/go.mod ebpf/go.sum | xargs sed -i 's#github.com/grafana/phlare#github.com/grafana/pyroscope#g' go mod tidy git add -A . git commit -m "Rename go import path" From 6abaac439453d4d0b5ea2cf5d4c25bf11eb2bb9a Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Tue, 18 Jul 2023 10:42:20 +0100 Subject: [PATCH 3/3] Use the real destination --- merge-repos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merge-repos.sh b/merge-repos.sh index e0c719e53..c7a4fda07 100755 --- a/merge-repos.sh +++ b/merge-repos.sh @@ -44,4 +44,4 @@ git remote add phlare "${WORK_DIR}/phlare" git fetch phlare git merge phlare/main --allow-unrelated-histories -m "The new Pyroscope" -git push git@github.com:simonswine/pyroscope HEAD:merged -f +git push git@github.com:grafana/pyroscope HEAD:next -f