diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-27 18:56:15 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-27 18:56:15 +0200 |
| commit | 69f17767abac2a31ffdaeebc6bc5997b102ffe92 (patch) | |
| tree | b0916e5e401cfb4b3cdd520e8cedd7aa355451a7 | |
| parent | 6c563f788d60acab6947637ea6e05eeef103abd1 (diff) | |
| download | bash-notes-69f17767abac2a31ffdaeebc6bc5997b102ffe92.tar.gz bash-notes-69f17767abac2a31ffdaeebc6bc5997b102ffe92.zip | |
Fix title, git toggle, push target, showconf and restore bugs
- addnote: use the title passed on the command line instead of
storing an empty one.
- USEGIT: test for the value true, so USEGIT=false actually
disables git even when GITREMOTE is set.
- git: push to origin HEAD instead of a hardcoded master branch.
- configtext: print GITCLIENT, already defaulted to hostname.
- backup_restore: replace the malformed .git test, always remove
the existing .git before copying the backup one.
- helptext/README: --backup requires a destination.
- README: add Development Approach section.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | SOURCE/CORE/core-add.sh | 2 | ||||
| -rw-r--r-- | SOURCE/CORE/core-backup.sh | 4 | ||||
| -rw-r--r-- | SOURCE/CORE/git.sh | 22 | ||||
| -rw-r--r-- | SOURCE/CORE/helpers.sh | 11 | ||||
| -rwxr-xr-x | notes.sh | 39 |
6 files changed, 44 insertions, 46 deletions
@@ -25,7 +25,7 @@ notes parameters are: -r | --restore=[<dir>] : Restore a previous backup from dir -v | --version : Print version --userconf : Export User config file - --backup [<dest>] : Backup your data in your destination folder + --backup=<dest> : Backup your data in your destination folder --showconf : Display running options --sync : Sync notes to git repository @@ -238,4 +238,12 @@ It'd mean so much to receive some feedback, patches if you feel like contributin ### LICENSE -> bash-notes © 2023 by danix is licensed under CC BY-NC 4.0. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/
\ No newline at end of file +> bash-notes © 2023 by danix is licensed under CC BY-NC 4.0. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/ + +## Development Approach + +This project is developed using AI-assisted tools. Code is generated with the help of AI based on human-provided specifications, design decisions, and iterative feedback. + +All contributions are reviewed, tested, and curated by the maintainer before being included in the codebase. AI is used as a productivity and exploration tool, while human oversight remains central to all decisions. + +The goal is to combine the flexibility of AI-assisted development with standard open-source practices such as transparency, review, and accountability. diff --git a/SOURCE/CORE/core-add.sh b/SOURCE/CORE/core-add.sh index 3404f71..927f191 100644 --- a/SOURCE/CORE/core-add.sh +++ b/SOURCE/CORE/core-add.sh @@ -19,6 +19,8 @@ addnote() { NOTETITLE=$TITLE ;; esac + else + NOTETITLE=$1 fi # [[ -z "$1" ]] && NOTETITLE="$RTITLE" || NOTETITLE="$1" diff --git a/SOURCE/CORE/core-backup.sh b/SOURCE/CORE/core-backup.sh index 7a0b6d1..f03782e 100644 --- a/SOURCE/CORE/core-backup.sh +++ b/SOURCE/CORE/core-backup.sh @@ -73,9 +73,7 @@ backup_restore() { fi # restoring git repo subdirectory if [ -d $BACKUPDIR/.git ]; then - if [ /bin/ls -A ${BASEDIR}/.git ]; then - rm -rf ${BASEDIR}/.git - fi + rm -rf "${BASEDIR}/.git" cp -r --verbose ${BACKUPDIR}/.git ${BASEDIR}/ fi ;; diff --git a/SOURCE/CORE/git.sh b/SOURCE/CORE/git.sh index 42c89a8..7be650f 100644 --- a/SOURCE/CORE/git.sh +++ b/SOURCE/CORE/git.sh @@ -19,7 +19,7 @@ is_git_repo() { # accepts -f parameter to skip last sync check gitsync() { FORCE=$1 - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Syncing notes with git on remote \"$GITREMOTE\"" NOWSYNC=$(date +%s) if [[ $FORCE == "-f" ]]; then @@ -50,12 +50,12 @@ gitsync() { # add note to git and push it to remote gitadd() { - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Adding note to remote \"$GITREMOTE\"" cd $BASEDIR $GIT add . $GIT commit -m "$(basename $0) - adding note from ${GITCLIENT}" - $GIT push origin master + $GIT push origin HEAD else # no git, so we just keep going true @@ -64,12 +64,12 @@ gitadd() { # edited note added to git and pushed it to remote gitedit() { - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Editing note on remote \"$GITREMOTE\"" cd $BASEDIR $GIT add . $GIT commit -m "$(basename $0) - ${GITCLIENT} note edited." - $GIT push origin master + $GIT push origin HEAD else # no git, so we just keep going true @@ -80,14 +80,14 @@ gitedit() { gitremove() { NOTE=$1 FILE=$2 - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Deleting notes from remote \"$GITREMOTE\"" if [ "all" == $NOTE ];then echo "Deleting all notes" cd $BASEDIR $GIT rm notes/* $GIT commit -m "$(basename $0) - ${GITCLIENT} removing all notes." - $GIT push origin master + $GIT push origin HEAD else local OK=$(check_noteID "$NOTE") if [[ "$OK" ]]; then @@ -96,7 +96,7 @@ gitremove() { $GIT rm notes/${FILE} $GIT add . $GIT commit -m "$(basename $0) - ${GITCLIENT} removing note ID ${NOTE}." - $GIT push origin master + $GIT push origin HEAD fi fi else @@ -106,7 +106,7 @@ gitremove() { } # check for USEGIT and subsequent variables -if [[ $USEGIT && -n $GITREMOTE ]]; then +if [[ $USEGIT == true && -n $GITREMOTE ]]; then # GIT is a go. if ! is_git_repo $BASEDIR; then # initializing git repository @@ -116,9 +116,9 @@ if [[ $USEGIT && -n $GITREMOTE ]]; then $GIT add . $GIT commit -m "$(basename $0) - initial commit from ${GITCLIENT}" $GIT remote add origin $GITREMOTE - $GIT push -u origin master + $GIT push -u origin HEAD fi -elif [[ $USEGIT && -z $GITREMOTE ]]; then +elif [[ $USEGIT == true && -z $GITREMOTE ]]; then echo "GITREMOTE variable not set. reverting USEGIT to false" USEGIT=false fi diff --git a/SOURCE/CORE/helpers.sh b/SOURCE/CORE/helpers.sh index f0d15d2..0612a46 100644 --- a/SOURCE/CORE/helpers.sh +++ b/SOURCE/CORE/helpers.sh @@ -28,7 +28,7 @@ helptext() { echo -e " -r | --restore=[<dir>]\t: Restore a previous backup from dir" echo -e " -v | --version\t\t: Print version" echo -e " --userconf\t\t\t: Export User config file" - echo -e " --backup [<dest>]\t\t: Backup your data in your destination folder" + echo -e " --backup=<dest>\t\t: Backup your data in your destination folder" echo -e " --showconf\t\t\t: Display running options" echo -e " --sync\t\t\t: Sync notes to git repository" echo "" @@ -36,12 +36,7 @@ helptext() { } configtext() { - [ $USEGIT ] && GITUSE="enabled" || GITUSE="disabled" - if [ -n $GITCLIENT ]; then - CLIENTGIT="$( hostname )" - else - CLIENTGIT="$GITCLIENT" - fi + [[ $USEGIT == true ]] && GITUSE="enabled" || GITUSE="disabled" clear echo -e "${BASENAME} configuration is:" @@ -59,7 +54,7 @@ configtext() { echo -e "\tGIT: ${GITUSE} - ${GIT}" echo -e "\tGIT remote: ${GITREMOTE}" echo -e "\tGIT sync delay: ${GITSYNCDELAY}" - echo -e "\tGIT client name: ${CLIENTGIT}" + echo -e "\tGIT client name: ${GITCLIENT}" } # this function returns a random 2 words title @@ -192,7 +192,7 @@ helptext() { echo -e " -r | --restore=[<dir>]\t: Restore a previous backup from dir" echo -e " -v | --version\t\t: Print version" echo -e " --userconf\t\t\t: Export User config file" - echo -e " --backup [<dest>]\t\t: Backup your data in your destination folder" + echo -e " --backup=<dest>\t\t: Backup your data in your destination folder" echo -e " --showconf\t\t\t: Display running options" echo -e " --sync\t\t\t: Sync notes to git repository" echo "" @@ -200,12 +200,7 @@ helptext() { } configtext() { - [ $USEGIT ] && GITUSE="enabled" || GITUSE="disabled" - if [ -n $GITCLIENT ]; then - CLIENTGIT="$( hostname )" - else - CLIENTGIT="$GITCLIENT" - fi + [[ $USEGIT == true ]] && GITUSE="enabled" || GITUSE="disabled" clear echo -e "${BASENAME} configuration is:" @@ -223,7 +218,7 @@ configtext() { echo -e "\tGIT: ${GITUSE} - ${GIT}" echo -e "\tGIT remote: ${GITREMOTE}" echo -e "\tGIT sync delay: ${GITSYNCDELAY}" - echo -e "\tGIT client name: ${CLIENTGIT}" + echo -e "\tGIT client name: ${GITCLIENT}" } # this function returns a random 2 words title @@ -276,7 +271,7 @@ is_git_repo() { # accepts -f parameter to skip last sync check gitsync() { FORCE=$1 - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Syncing notes with git on remote \"$GITREMOTE\"" NOWSYNC=$(date +%s) if [[ $FORCE == "-f" ]]; then @@ -307,12 +302,12 @@ gitsync() { # add note to git and push it to remote gitadd() { - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Adding note to remote \"$GITREMOTE\"" cd $BASEDIR $GIT add . $GIT commit -m "$(basename $0) - adding note from ${GITCLIENT}" - $GIT push origin master + $GIT push origin HEAD else # no git, so we just keep going true @@ -321,12 +316,12 @@ gitadd() { # edited note added to git and pushed it to remote gitedit() { - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Editing note on remote \"$GITREMOTE\"" cd $BASEDIR $GIT add . $GIT commit -m "$(basename $0) - ${GITCLIENT} note edited." - $GIT push origin master + $GIT push origin HEAD else # no git, so we just keep going true @@ -337,14 +332,14 @@ gitedit() { gitremove() { NOTE=$1 FILE=$2 - if [[ $USEGIT && -n $GITREMOTE ]]; then + if [[ $USEGIT == true && -n $GITREMOTE ]]; then [ $PLAIN == false ] && echo "Deleting notes from remote \"$GITREMOTE\"" if [ "all" == $NOTE ];then echo "Deleting all notes" cd $BASEDIR $GIT rm notes/* $GIT commit -m "$(basename $0) - ${GITCLIENT} removing all notes." - $GIT push origin master + $GIT push origin HEAD else local OK=$(check_noteID "$NOTE") if [[ "$OK" ]]; then @@ -353,7 +348,7 @@ gitremove() { $GIT rm notes/${FILE} $GIT add . $GIT commit -m "$(basename $0) - ${GITCLIENT} removing note ID ${NOTE}." - $GIT push origin master + $GIT push origin HEAD fi fi else @@ -363,7 +358,7 @@ gitremove() { } # check for USEGIT and subsequent variables -if [[ $USEGIT && -n $GITREMOTE ]]; then +if [[ $USEGIT == true && -n $GITREMOTE ]]; then # GIT is a go. if ! is_git_repo $BASEDIR; then # initializing git repository @@ -373,9 +368,9 @@ if [[ $USEGIT && -n $GITREMOTE ]]; then $GIT add . $GIT commit -m "$(basename $0) - initial commit from ${GITCLIENT}" $GIT remote add origin $GITREMOTE - $GIT push -u origin master + $GIT push -u origin HEAD fi -elif [[ $USEGIT && -z $GITREMOTE ]]; then +elif [[ $USEGIT == true && -z $GITREMOTE ]]; then echo "GITREMOTE variable not set. reverting USEGIT to false" USEGIT=false fi @@ -401,6 +396,8 @@ addnote() { NOTETITLE=$TITLE ;; esac + else + NOTETITLE=$1 fi # [[ -z "$1" ]] && NOTETITLE="$RTITLE" || NOTETITLE="$1" @@ -497,9 +494,7 @@ backup_restore() { fi # restoring git repo subdirectory if [ -d $BACKUPDIR/.git ]; then - if [ /bin/ls -A ${BASEDIR}/.git ]; then - rm -rf ${BASEDIR}/.git - fi + rm -rf "${BASEDIR}/.git" cp -r --verbose ${BACKUPDIR}/.git ${BASEDIR}/ fi ;; |
