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

Add repo merge script #808

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions merge-repos.sh
Original file line number Diff line number Diff line change
@@ -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 [email protected]:grafana/pyroscope.git "${WORK_DIR}/og"
git clone [email protected]: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 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"

# 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 [email protected]:grafana/pyroscope HEAD:next -f
Loading