Skip to content

Commit 43e0859

Browse files
committed
Revert "get rid of empty spaces"
This reverts commit 00af85e.
1 parent 00af85e commit 43e0859

6 files changed

Lines changed: 174 additions & 182 deletions

bin/delete-everything-split-repo.sh

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2022 Google LLC
2+
# Copyright 202 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -23,15 +23,32 @@ fi
2323

2424
# repo name (e.g. nodejs-asset)
2525
SPLIT_REPO=$1
26-
# destination directory (e.g. packages/google-cloud-asset)
26+
# destination directory (e.g. google-cloud-asset)
2727
ARTIFACT_NAME=$2
2828

2929
rm -rf "/tmp/${SPLIT_REPO}"
3030
git clone "git@github.com:googleapis/${SPLIT_REPO}.git" "/tmp/${SPLIT_REPO}"
3131

3232
cd "/tmp/${SPLIT_REPO}"
3333

34-
git checkout -b 'archiveLibrary'
34+
git checkout -b 'deleteMostOfLibrary'
35+
36+
37+
# Delete everything first that's not the samples, README.md, .kokoro folder, and git folder
38+
ls | grep -v 'samples\|README.md\|.git' | xargs rm -rf
39+
rm -rf "/tmp/${SPLIT_REPO}/.[!.git]*"
40+
rm -rf "/tmp/${SPLIT_REPO}/.github"
41+
rm -rf "/tmp/${SPLIT_REPO}/.kokoro"
42+
43+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/presubmit/node12/common.cfg"
44+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/presubmit/node12/samples-test.cfg"
45+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/presubmit/node12/system-test.cfg"
46+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/presubmit/node12/test.cfg"
47+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/common.cfg"
48+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/populate-secrets.sh"
49+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/trampoline.sh"
50+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/trampoline_v2.sh"
51+
git checkout "/tmp/${SPLIT_REPO}/.kokoro/.gitattributes"
3552

3653
IGNORE_README_TXT="# Copyright 2022 Google LLC
3754
#
@@ -55,24 +72,101 @@ OWLBOT_PY="/tmp/${SPLIT_REPO}/owlbot.py"
5572

5673
echo "$IGNORE_README_TXT" >> "$OWLBOT_PY"
5774

75+
SAMPLES_CFG_TXT="#!/bin/bash
76+
# Copyright 2022 Google LLC
77+
#
78+
# Licensed under the Apache License, Version 2.0 (the "License");
79+
# you may not use this file except in compliance with the License.
80+
# You may obtain a copy of the License at
81+
#
82+
# https://www.apache.org/licenses/LICENSE-2.0
83+
#
84+
# Unless required by applicable law or agreed to in writing, software
85+
# distributed under the License is distributed on an \"AS IS\" BASIS,
86+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
87+
# See the License for the specific language governing permissions and
88+
# limitations under the License.
89+
set -eo pipefail
90+
export NPM_CONFIG_PREFIX=\${HOME}/.npm-global
91+
# Setup service account credentials.
92+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-accountexport GCLOUD_PROJECT=long-door-651
93+
cd \$(dirname \$0)/..
94+
# Run a pre-test hook, if a pre-samples-test.sh is in the project
95+
if [ -f .kokoro/pre-samples-test.sh ]; then
96+
set +x
97+
. .kokoro/pre-samples-test.sh
98+
set -x
99+
fi
100+
if [ -f samples/package.json ]; then
101+
# Install and link samples
102+
cd samples/
103+
npm install
104+
# If tests are running against main branch, configure flakybot
105+
# to open issues on failures:
106+
if [[ \$KOKORO_BUILD_ARTIFACTS_SUBDIR = *\"continuous\"* ]] || [[ \$KOKORO_BUILD_ARTIFACTS_SUBDIR = *\"nightly\"* ]]; then
107+
export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml
108+
export MOCHA_REPORTER=xunit
109+
cleanup() {
110+
chmod +x \$KOKORO_GFILE_DIR/linux_amd64/flakybot
111+
\$KOKORO_GFILE_DIR/linux_amd64/flakybot
112+
}
113+
trap cleanup EXIT HUP
114+
fi
115+
npm run test
116+
fi
117+
# codecov combines coverage across integration and unit tests. Include
118+
# the logic below for any environment you wish to collect coverage for:
119+
COVERAGE_NODE=12
120+
if npx check-node-version@3.3.0 --silent --node \$COVERAGE_NODE; then
121+
NYC_BIN=./node_modules/nyc/bin/nyc.js
122+
if [ -f \"\$NYC_BIN\" ]; then
123+
\$NYC_BIN report || true
124+
fi
125+
bash \$KOKORO_GFILE_DIR/codecov.sh
126+
else
127+
echo \"coverage is only reported for Node \$COVERAGE_NODE\"
128+
fi"
129+
130+
SYSTEM_TEST_CFG_TXT="#!/bin/bash
131+
# Copyright 2022 Google LLC
132+
#
133+
# Licensed under the Apache License, Version 2.0 (the \"License\");
134+
# you may not use this file except in compliance with the License.
135+
# You may obtain a copy of the License at
136+
#
137+
# https://www.apache.org/licenses/LICENSE-2.0
138+
#
139+
# Unless required by applicable law or agreed to in writing, software
140+
# distributed under the License is distributed on an \"AS IS\" BASIS,
141+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142+
# See the License for the specific language governing permissions and
143+
# limitations under the License.
144+
set -eo pipefail
145+
echo \"no-op\"
146+
"
147+
148+
echo "$SAMPLES_CFG_TXT" >> "/tmp/${SPLIT_REPO}/.kokoro/samples-test.sh"
149+
echo "$SYSTEM_TEST_CFG_TXT" >> "/tmp/${SPLIT_REPO}/.kokoro/system-test.sh"
150+
chmod u+x "/tmp/${SPLIT_REPO}/.kokoro/samples-test.sh"
151+
chmod u+x "/tmp/${SPLIT_REPO}/.kokoro/system-test.sh"
58152

59153
# Update the README
60154
README_MD="/tmp/${SPLIT_REPO}/README.md"
61155

62156
README_CONTENT=$(cat $README_MD)
63-
echo -e "**_THIS REPOSITORY IS DEPRECATED. ALL OF ITS CONTENT AND HISTORY HAS BEEN MOVED TO [GOOGLE-CLOUD-NODE](https://github.com/googleapis/google-cloud-node/tree/main/handwritten)_**\n\n$README_CONTENT" > "$README_MD"
157+
echo -e "**_THIS REPOSITORY IS DEPRECATED. ALL OF ITS CONTENT AND HISTORY HAS BEEN MOVED TO [GOOGLE-CLOUD-NODE](https://github.com/googleapis/google-cloud-node/tree/main/packages/${ARTIFACT_NAME})_**\n\n$README_CONTENT" > "$README_MD"
64158

65159
git add .
66-
git commit -m 'build: update README for deprecation notice'
160+
git commit -m 'build: update README for deprecation notice and delete all files except samples'
67161

68-
git push -f --set-upstream origin archiveLibrary
162+
git push -f --set-upstream origin deleteMostOfLibrary
69163

70164
# create pull request
71165
if gh --help > /dev/null
72166
then
73-
gh pr create --title "build: update README for deprecation notice"
167+
gh pr create --title "build: update README for deprecation notice and delete all files except samples"
74168
else
75-
hub pull-request -m "build: update README for deprecation notice"
169+
hub pull-request -m "build: update README for deprecation notice and delete all files except samples"
76170
fi
77171

78172
rm -rf "/tmp/${SPLIT_REPO}"

bin/generate-readme.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async function downloadRepoMetadata () {
6666

6767
let meta;
6868
for (const urlandRepo of urlsAndRepos) {
69-
try {
69+
try {
7070
const res = await github.request({ url: urlandRepo.url });
7171
meta = JSON.parse(
7272
Buffer.from(res.data.content, 'base64').toString('utf8')
@@ -156,7 +156,7 @@ async function processMetadata (repoMetadata) {
156156
if (!supportDocsUrl.match(/^https/)) {
157157
supportDocsUrl = `https://${supportDocsUrl}`
158158
}
159-
159+
160160
let res;
161161
let remoteUrlExists = true;
162162
// if URL doesn't exist, fall back to the generic docs page

bin/migrate-git-history.sh

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,12 @@ export FILTER_BRANCH_SQUELCH_WARNING=1
5858
WORKDIR=$(mktemp -d -t code-migration-XXXXXXXXXX)
5959
echo "Created working directory: ${WORKDIR}"
6060

61-
# Define persistent cache directory for source repositories
62-
SOURCE_REPO_CACHE_ROOT="${HOME}/.gemini-cli/git-cache"
63-
SOURCE_REPO_CACHE_DIR="${SOURCE_REPO_CACHE_ROOT}/$(basename "${SOURCE_REPO}")"
64-
6561
pushd "${WORKDIR}"
6662

67-
echo "Checking for cached source repository: ${SOURCE_REPO_CACHE_DIR}"
68-
if [[ -d "${SOURCE_REPO_CACHE_DIR}" && -d "${SOURCE_REPO_CACHE_DIR}/.git" ]]
69-
then
70-
echo "Cached source repository found. Updating..."
71-
pushd "${SOURCE_REPO_CACHE_DIR}"
72-
git pull
73-
popd
74-
else
75-
echo "Cached source repository not found. Cloning into ${SOURCE_REPO_CACHE_DIR}..."
76-
mkdir -p "${SOURCE_REPO_CACHE_ROOT}"
77-
git clone "git@github.com:${SOURCE_REPO}.git" "${SOURCE_REPO_CACHE_DIR}"
78-
fi
63+
echo "Cloning source repository: ${SOURCE_REPO}"
64+
git clone "git@github.com:${SOURCE_REPO}.git" source-repo
7965

80-
pushd "${SOURCE_REPO_CACHE_DIR}"
66+
pushd source-repo
8167
git remote remove origin
8268

8369
# prune only files within the specified directory
@@ -106,9 +92,9 @@ then
10692
if [[ $file == "${KEEP_FILES_SPACES[$LAST_ELEMENT]}" ]]
10793
then
10894
KEEP_FILE_COMMANDS+="git checkout -- ${file} 2>/dev/null || true"
109-
else
95+
else
11096
KEEP_FILE_COMMANDS+="git checkout -- ${file} 2>/dev/null || true; "
111-
fi
97+
fi
11298
done
11399
# restore files to keep, silence errors if the file doesn't exist
114100
FILTER="${FILTER}; ${KEEP_FILE_COMMANDS}"
@@ -134,17 +120,17 @@ fi
134120
popd
135121

136122
# merge histories
137-
echo "Cloning target repository: ${TARGET_REPO}"
123+
echo "Cloning target repository: ${SOURCE_REPO}"
138124
git clone "git@github.com:${TARGET_REPO}.git" target-repo
139125
pushd target-repo
140126

141-
git remote add --fetch migration "${SOURCE_REPO_CACHE_DIR}"
127+
git remote add --fetch migration ../source-repo
142128
git checkout -b "${BRANCH}"
143129
git merge --allow-unrelated-histories migration/main --no-edit
144130

145131
if [[ ! -z "${UPDATE_SCRIPT}" ]]
146132
then
147-
bash "${UPDATE_SCRIPT}" "${PACKAGE_PATH}"
133+
bash "${UPDATE_SCRIPT}"
148134
fi
149135

150136
git push -u origin "${BRANCH}" --force

bin/migrate-split-repo.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,36 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
15+
1616
set -e
17-
17+
1818
if [ $# -lt 2 ]
1919
then
2020
echo "Usage: $0 <split-repo-name> <target-path>"
2121
exit 1
2222
fi
23-
23+
2424
# repo name (e.g. nodejs-asset)
25-
export SPLIT_REPO=$1
26-
# destination directory (e.g. packages/google-cloud-asset)
27-
export PACKAGE_PATH="$2"
28-
25+
SPLIT_REPO=$1
26+
# destination directory (e.g. google-cloud-asset)
27+
ARTIFACT_NAME=$2
28+
2929
## Get the directory of the build script
3030
SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}"))
31-
31+
3232
export UPDATE_SCRIPT="${SCRIPT_DIR}/split-repo-post-process.sh"
33+
export PACKAGE_PATH="packages/${ARTIFACT_NAME}"
34+
3335
# run the migrate script, remove .kokoro and .github folders
3436
# keep the .github/.OwlBot.yaml config
3537
${SCRIPT_DIR}/migrate-git-history.sh \
3638
"googleapis/${SPLIT_REPO}" \
3739
"googleapis/google-cloud-node" \
3840
"" \
3941
"${PACKAGE_PATH}" \
40-
"samples",".github/workflows/ci.yaml,.github/workflows/issues-no-repro.yaml,.github/workflows/response.yaml,SECURITY.md,renovate.json" \
41-
"samples/generated",".github/.OwlBot.yaml,system-test/test/quickstart.js,system-test/test/quickstart.test.js"
42-
42+
".kokoro,.github,.trampolinerc,SECURITY.md,renovate.json,samples" \
43+
".github/.OwlBot.yaml,samples/quickstart.js,samples/test/quickstart.js,system-test/test/quickstart.js,samples/.eslintrc.yml,samples/test/sample.test.js,samples/test/quickstart.test.js,system-test/test/quickstart.test.js,system-test/test/quickstart.js,samples/README.md,samples/package.json,samples/generated"
4344

44-
${SCRIPT_DIR}/update-readme-only-split-repo.sh "${SPLIT_REPO}" "${ARTIFACT_NAME}"
45+
# run the script to update the split repo and either delete all the samples or just update the README
46+
${SCRIPT_DIR}/delete-everything-split-repo.sh "${SPLIT_REPO}" "${ARTIFACT_NAME}"
47+
${SCRIPT_DIR}/update-readme-only-split-repo.sh "${SPLIT_REPO}" "${ARTIFACT_NAME}"

0 commit comments

Comments
 (0)