remove old shell script
This commit is contained in:
parent
3cb385044d
commit
3d8623e6d5
1 changed files with 0 additions and 44 deletions
44
update
44
update
|
@ -1,44 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
update() {
|
||||
url="$1"
|
||||
pad="$(basename "$url").txt"
|
||||
dst="$gitdir/$pad"
|
||||
|
||||
curl --silent -k -o "${dst}" "${url}/export/txt"
|
||||
status="$?"
|
||||
if [ ${status} -ne 0 ]; then
|
||||
echo -e "\e[1;31mFailed to get pad at ${url}\e[0m"
|
||||
return
|
||||
fi
|
||||
|
||||
newlength="$(wc -l < "${dst}")"
|
||||
if [ "$newlength" -lt 3 ]
|
||||
then
|
||||
echo -e "\e[1;33mSkipping update of ${url}, because pad has likely been removed\e[0m"
|
||||
return
|
||||
fi
|
||||
|
||||
git -C "${gitdir}" add "${dst}"
|
||||
changes=$(git -C "${gitdir}" diff --cached | wc -l)
|
||||
if [ "$changes" -lt 1 ]; then
|
||||
echo -e "\e[1;34mNothing changed for ${url}\e[0m"
|
||||
return
|
||||
fi
|
||||
|
||||
git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}" > /dev/null
|
||||
echo "\e[1;32mUpdated ${dst} from ${url}\e[0m"
|
||||
}
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1
|
||||
then
|
||||
echo -e "\e[1;31mNot a git directory\e[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gitdir="$(realpath "${1:-$PWD}")"
|
||||
while read -r pad
|
||||
do
|
||||
update "$pad"
|
||||
git -C "${gitdir}" reset --hard HEAD > /dev/null
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue