forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate_rust_dev_preview.sh
executable file
·52 lines (40 loc) · 1.24 KB
/
migrate_rust_dev_preview.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
SRC=rust_dev_preview
DEST=rustv1
git restore --staged .
git restore .
rm -rf $DEST
# List git text files, so we don't grep through
git-ls-text-files() {
git ls-files "${@:1}" | while read -r file; do
if file --brief "$file" | grep -q text; then
echo "$file"
fi
done
}
FOLDERS=(
.doc_gen
.github
.tools
applications
resources
"$SRC"
)
# Replace path across repo: rust_dev_preview with rust
RE="/snippet-(start|end)/!s/$SRC/$DEST/g"
git-ls-text-files "${FOLDERS[@]}" | xargs sed -i '' -e "$RE"
# Not sure why these are getting skipped?
sed -i '' -e "$RE" README.md rust_dev_preview/**/{Dockerfile,*.py}
# Remove SDKs caveat
sed -i '' -e '/ caveat: "This documentation is for an SDK in preview release. The SDK is subject to change and should not be used in production."/d' .doc_gen/metadata/sdks.yaml
# Move files mv rust_dev_preview rust
mv $SRC $DEST
# Create symlink for forwarding
ln -s $DEST $SRC
.tools/readmes/multi.py --languages Rust:1 --no-dry-run
git add .
# git restore --staged migrate_rust_dev_preview.sh
echo "Remaining usages of $SRC":
git ls-files . | xargs grep $SRC 2>/dev/null