aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.com>2021-11-19 23:05:25 +0200
committerkaotisk <kaotisk@arching-kaos.com>2021-11-19 23:05:25 +0200
commit3144d9037983d750d2e0bca22c8a1dd6910dbb7a (patch)
tree5cda5d259932150b4c2b30169684e00fa56c0add
parentc5c44855b3df2e1af900e3c35af7ac77d02ae1bd (diff)
download01-NEWS-3144d9037983d750d2e0bca22c8a1dd6910dbb7a.tar.gz
01-NEWS-3144d9037983d750d2e0bca22c8a1dd6910dbb7a.tar.bz2
01-NEWS-3144d9037983d750d2e0bca22c8a1dd6910dbb7a.zip
Minor update on add-new.sh script, introducing a migration tool for the changes
-rwxr-xr-x20210525_0828402
-rwxr-xr-xbin/add-new.sh9
-rwxr-xr-xbin/migrate.sh13
3 files changed, 21 insertions, 3 deletions
diff --git a/20210525_082840 b/20210525_082840
index 61dfd16..4c01117 100755
--- a/20210525_082840
+++ b/20210525_082840
@@ -1,4 +1,4 @@
-[NEWS] Created script to quickly add news to the repo
+Created script to quickly add news to the repo
I only use timestamp for file name. I open an editor for that and from there, the first line is the title as happens most of the times.
diff --git a/bin/add-new.sh b/bin/add-new.sh
index c82bc70..086cff8 100755
--- a/bin/add-new.sh
+++ b/bin/add-new.sh
@@ -1,5 +1,10 @@
#!/bin/bash
export NEWS_FILE="$(date +%Y%m%d_%H%M%S)"
vi $NEWS_FILE
-git add $NEWS_FILE
-git commit -m "$(head -n 1 $NEWS_FILE)"
+echo "Renaming..."
+TITLE="$(head -n 1 $NEWS_FILE)"
+TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' )
+mv $NEWS_FILE $TO_FILE
+echo "Adding to git repo..."
+git add $TO_FILE
+git commit -m "Added $NEWS_FILE with $(head -n 1 $TO_FILE)"
diff --git a/bin/migrate.sh b/bin/migrate.sh
new file mode 100755
index 0000000..8b6db20
--- /dev/null
+++ b/bin/migrate.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+echo "Migration tool: please run only once"
+FILES=$(ls -1 | grep 202)
+for file in $FILES; do
+ if [ -f $file ]
+ then
+ title="$(head -n 1 $file)"
+ new_name="$file-$(echo "$title" | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g')"
+ mv $file $new_name
+ git add $file $new_name
+ git commit -m "Migrated to new naming $file to $new_name";
+ fi
+done