Skip to content

Commit ab595b4

Browse files
committed
Adding more descirption in the script
1 parent c756268 commit ab595b4

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

generation/merge_repository.sh

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
#!/bin/bash
22

3+
# Merging repository to google-cloud-java using git-filter-repo.
34
# https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories
5+
#
6+
# Usage:
7+
# cd google-cloud-java
8+
# # edit the repository to merge.
9+
# vim generation/repo.txt
10+
# # use your account
11+
# export USERNAME=XXX
12+
# # Run the script
13+
# ./generation/merge_repository.sh
14+
# # Create a pull request. Ensure you MERGE the pull request. Not 'squash'.
15+
# cd generation/monorepo/google-cloud-java-merged
16+
# git checkout -b merge_repositories
17+
# gh pr create --title 'chore: merge new repository into google-cloud-java' --body ''
418

519
set -xe
620

@@ -33,23 +47,25 @@ do
3347
git filter-repo --to-subdirectory-filter ${service}
3448

3549
# setup owlbot files correctly to match monorepo configuration
36-
cp ${service}/.github/.OwlBot.yaml ${service}/.OwlBot.yaml
37-
rm ${service}/.github/.OwlBot.lock.yaml
38-
rm ${service}/.github/.OwlBot.yaml
39-
sed -i.bak '/docker/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak
40-
sed -i.bak '/image/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak
41-
42-
# In monorepo, the staging directory structure tells the destination module to
43-
# which the OwlBot Java postprocessor copies the files.
44-
sed -i.bak "s|owl-bot-staging|owl-bot-staging/${service}|" ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak
45-
46-
text=$(grep '^.*api_shortname.*' ${service}/.repo-metadata.json)
47-
text=$(echo "$text" | sed 's/\"//g; s/\,//g; s/^[[:space:]]*//' )
48-
text=${text/api_shortname/api-name}
49-
echo -e "\n"$text>> ${service}/.OwlBot.yaml
50-
git add .
51-
git config --add secrets.allowed "dest.*src"
52-
git commit -am "chore: setup owlbot configuration"
50+
if [ -r "${service}/.github/.OwlBot.yaml" ]; then
51+
cp ${service}/.github/.OwlBot.yaml ${service}/.OwlBot.yaml
52+
rm ${service}/.github/.OwlBot.lock.yaml
53+
rm ${service}/.github/.OwlBot.yaml
54+
sed -i.bak '/docker/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak
55+
sed -i.bak '/image/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak
56+
57+
# In monorepo, the staging directory structure tells the destination module to
58+
# which the OwlBot Java postprocessor copies the files.
59+
sed -i.bak "s|owl-bot-staging|owl-bot-staging/${service}|" ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak
60+
61+
text=$(grep '^.*api_shortname.*' ${service}/.repo-metadata.json)
62+
text=$(echo "$text" | sed 's/\"//g; s/\,//g; s/^[[:space:]]*//' )
63+
text=${text/api_shortname/api-name}
64+
echo -e "\n"$text>> ${service}/.OwlBot.yaml
65+
git add .
66+
git config --add secrets.allowed "dest.*src"
67+
git commit -am "chore: setup owlbot configuration"
68+
fi
5369

5470
cd "../${merged_repository}"
5571
git remote add ${service} ../${service}
@@ -74,6 +90,9 @@ git commit -m 'chore: add template files'
7490
git add pom.xml
7591
git commit -am 'chore: create aggregator pom' --allow-empty
7692

93+
echo "Not doing something special for java-core, java-shared-dependencies, and java-iam"
94+
exit 0
95+
7796
# Point modules poms and BOMs to the aggregator pom as parent
7897
bash ../../set_parent_pom.sh
7998

@@ -158,4 +177,4 @@ git commit -m 'split repo - diff versions.txt' --allow-empty
158177

159178
git add --all || true
160179
git commit -am 'split repo - diff everything else' --allow-empty
161-
cd ../..
180+
cd ../..

0 commit comments

Comments
 (0)