GithubHelp home page GithubHelp logo

Comments (12)

CharlesChiuGit avatar CharlesChiuGit commented on July 30, 2024

Did you use the exact git-hooks files I provided?
line 11 shouldn't execute anything at all.

from logseq-git-sync-101.

neon-moon avatar neon-moon commented on July 30, 2024

I was using the exact sheet, but took those two commented lines out that were at line 11 to see if it was causing the issue. Now I have the below script and get the below message, which lines up with the if statement that seems to be causing the issue.

#!/bin/sh
#
# Pull before committing
# Credential handling options:
#  - hardcode credentials in URL 
#  - use ssh with key auth 
#  - https://git-scm.com/docs/git-credential-store
#  - git credential helper on windows

output=$(git pull --no-rebase)

# Handle non error output as otherwise it gets shown with any exit code by logseq
if [[ "$output" == "Already up to date." ]]; then
   # no ouput
   exit 0
else
   # probably error print it to screen   
   echo $output
fi

git add -A
10:36:03.482 › [Git] .git/hooks/pre-commit: 13: [[: not found
Already up to date.

from logseq-git-sync-101.

CharlesChiuGit avatar CharlesChiuGit commented on July 30, 2024

Maybe the space character or the newline character are having issues on windows and linux.
I don't think it's a big problem. But if you very want to get rid of it, maybe you can re-type the pre-commits. Remember to use the .sample files in the .git/hooks as template because the file type is very unique.

from logseq-git-sync-101.

neon-moon avatar neon-moon commented on July 30, 2024

Once I made the slight modifications below it began working. May be useful to note for any additional Linux users. I didn't dive too much farther into it, but I am assuming the sh interpreter does not include the double brackets as valid if syntax or something along those lines.

Thanks again for putting this all together, very excited to get this all integrated!

#!/bin/sh

output=$(git pull --no-rebase)

# Handle non error output as otherwise it gets shown with any exit code by logseq
if [ "$output" = "Already up to date." ]
then
   # no ouput
   exit 0
else
   # probably error print it to screen
   echo "else"
   # echo $output
fi

git add -A

from logseq-git-sync-101.

CharlesChiuGit avatar CharlesChiuGit commented on July 30, 2024

Interesting!
If it's the interpreter that goes wrong, maybe you can try replace #!/bin/bash with #!/bin/sh

from logseq-git-sync-101.

romilly avatar romilly commented on July 30, 2024

It's not the interpreter. It's a bug in your pre-commit script, which has [[ ]] instead of [ ].

I'll do a pr later.

from logseq-git-sync-101.

CharlesChiuGit avatar CharlesChiuGit commented on July 30, 2024

@romilly thanks! So my pre-commit script will act differently on different platform? Is there a more robust way to do it?

from logseq-git-sync-101.

romilly avatar romilly commented on July 30, 2024

I'm no expert, and I have no access to Windows or OS/X - Linux only I'm afraid.

Also I am now getting a (slightly different) error. I'll do a PR when it's working :)

from logseq-git-sync-101.

CharlesChiuGit avatar CharlesChiuGit commented on July 30, 2024

Cool!

from logseq-git-sync-101.

romilly avatar romilly commented on July 30, 2024

Doh! The code is fine, it's the difference between sh and bash on recent Linuxes.

With #!/bin/bash as the shebang, all works.

from logseq-git-sync-101.

romilly avatar romilly commented on July 30, 2024

And thanks for an excellent guide!

from logseq-git-sync-101.

CharlesChiuGit avatar CharlesChiuGit commented on July 30, 2024

Cool! So just the shebang? [[ ]] is actuacally fine? If that's the only problem I'll fix it right now.

from logseq-git-sync-101.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.