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

Commit

Permalink
Add repo merge script
Browse files Browse the repository at this point in the history
  • Loading branch information
simonswine committed Jun 30, 2023
1 parent f331ff6 commit 57d3d85
Showing 1 changed file with 47 additions and 0 deletions.
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 | 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]:simonswine/pyroscope HEAD:merged -f

0 comments on commit 57d3d85

Please sign in to comment.