moved and edited git folder scripts
This commit is contained in:
38
unzip-git.sh
Executable file
38
unzip-git.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
shopt -s nullglob
|
||||
matches=(worker-toolkit-*/repo)
|
||||
shopt -u nullglob
|
||||
|
||||
if [ ${#matches[@]} -eq 0 ]; then
|
||||
echo "No worker-toolkit-*/repo folder found, nothing to do." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${#matches[@]} -gt 1 ]; then
|
||||
echo "Multiple worker-toolkit-*/repo folders found, refusing to guess:" >&2
|
||||
printf ' %s\n' "${matches[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target="${matches[0]}"
|
||||
|
||||
if [ ! -f "$target/GITFOLDER.zip" ]; then
|
||||
echo "$target/GITFOLDER.zip not found, nothing to do." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d "$target/.git" ]; then
|
||||
echo "$target/.git folder already exists, refusing to overwrite." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$target"
|
||||
unzip -q GITFOLDER.zip
|
||||
)
|
||||
|
||||
echo "Unzipped $target/GITFOLDER.zip into $target/.git folder."
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
if [ ! -f GITFOLDER.zip ]; then
|
||||
echo "GITFOLDER.zip not found, nothing to do." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d .git ]; then
|
||||
echo ".git folder already exists, refusing to overwrite." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unzip -q GITFOLDER.zip
|
||||
|
||||
echo "Unzipped GITFOLDER.zip into .git folder."
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
echo ".git folder not found, nothing to do." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
zip -rq GITFOLDER.zip .git
|
||||
rm -rf .git
|
||||
|
||||
echo "Zipped .git into GITFOLDER.zip and removed .git folder."
|
||||
34
zip-git.sh
Executable file
34
zip-git.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
shopt -s nullglob
|
||||
matches=(worker-toolkit-*/repo)
|
||||
shopt -u nullglob
|
||||
|
||||
if [ ${#matches[@]} -eq 0 ]; then
|
||||
echo "No worker-toolkit-*/repo folder found, nothing to do." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${#matches[@]} -gt 1 ]; then
|
||||
echo "Multiple worker-toolkit-*/repo folders found, refusing to guess:" >&2
|
||||
printf ' %s\n' "${matches[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target="${matches[0]}"
|
||||
|
||||
if [ ! -d "$target/.git" ]; then
|
||||
echo ".git folder not found in $target, nothing to do." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$target"
|
||||
zip -rq GITFOLDER.zip .git
|
||||
rm -rf .git
|
||||
)
|
||||
|
||||
echo "Zipped .git into $target/GITFOLDER.zip and removed $target/.git folder."
|
||||
Reference in New Issue
Block a user