Code Monkey home page Code Monkey logo

Comments (12)

tswsl1989 avatar tswsl1989 commented on April 27, 2024 1

The following patch seems to have been enough to get the software up and running for me, should anyone want a stopgap until a proper fix is available:

diff --git a/gitcommands.go b/gitcommands.go
index 50c1f2a..63d2ffa 100644
--- a/gitcommands.go
+++ b/gitcommands.go
@@ -116,7 +116,7 @@ func platformShell() (string, string) {
        if runtime.GOOS == "windows" {
                return "cmd", "/c"
        }
-       return "sh", "-c"
+       return "bash", "-c"
 }

 func runDirectCommand(command string) (string, error) {

from lazygit.

jesseduffield avatar jesseduffield commented on April 27, 2024 1

thanks @tswsl1989 :) I switched to sh thinking it would increase compatibility but it seems it's had the opposite effect! I've added that change to the PR that should fix the underlying issue here #60
Feel free to give it a review

from lazygit.

jesseduffield avatar jesseduffield commented on April 27, 2024

hmm, it shouldn't be showing that error like that anymore. It looks like you're up to date in terms of the lazygit repo. Could you try running go install github.com/jesseduffield/lazygit to build the latest version?

from lazygit.

SolitudeSF avatar SolitudeSF commented on April 27, 2024

you shouldn't be using [[ bashism at all. its not posix.

from lazygit.

ph03 avatar ph03 commented on April 27, 2024

Seeing same issue on f8ca0dd with ubuntu 1804 (using fish shell, not zsh, but bash doesn't work either).

from lazygit.

jesseduffield avatar jesseduffield commented on April 27, 2024

The culprit is this script here which gets your branches in reverse chronological order along with their relative last commit time.

set -e
git reflog -n100 --pretty='%cr|%gs' --grep-reflog='checkout: moving' HEAD | {
  seen=":"
  git_dir="$(git rev-parse --git-dir)"
  while read line; do
    date="${line%%|*}"
    branch="${line##* }"
    if ! [[ $seen == *:"${branch}":* ]]; then
      seen="${seen}${branch}:"
      if [ -f "${git_dir}/refs/heads/${branch}" ]; then
        printf "%s\t%s\n" "$date" "$branch"
      fi
    fi
  done \
  | sed 's/ months /m /g' \
  | sed 's/ month /m /g' \
  | sed 's/ days /d /g' \
  | sed 's/ day /d /g' \
  | sed 's/ weeks /w /g' \
  | sed 's/ week /w /g' \
  | sed 's/ hours /h /g' \
  | sed 's/ hour /h /g' \
  | sed 's/ minutes /m /g' \
  | sed 's/ minute /m /g' \
  | sed 's/ seconds /s /g' \
  | sed 's/ second /s /g' \
  | sed 's/ago//g' \
  | tr -d ' '
}

example output:
19h	feature/better-file-opening
65m	master
65m	feature/use-dep
3h	hotfix/windows-support
5h	feature/fetching-without-checking-out
2w	develop
24h	feature/gpgsign-support
23h	feature/no-panic-on-git-commit-error
9h	hotfix/latency
30h	feature/refactor-directory-structure
26h	feature/better-contrast
2d	feature/set-upstream-on-push
2d	feature/testing-setting-upstream
2d	feature/tutorial6

It's probably the weakest part of the codebase, not the least because it hasn't been written in go. If anybody can put up a PR that cleans this guy up or refactors it out into just git commands and Go, I would very much appreciate it! I'll spend some time right now seeing if I can refactor it

from lazygit.

perror avatar perror commented on April 27, 2024

Beware, the go installer still install the buggy version (I tried a few minutes ago).

And, going to sh do improve portability (especially on plate-forms that do not have bash by default), but you have to care about the fact that all your shell commands are POSIX compliant (these [[ in place of test have to be avoided).

from lazygit.

jesseduffield avatar jesseduffield commented on April 27, 2024

@perror I just merged the PR to master, that ugly bash script is now out of the codebase. Let me know if there are still any issues

from lazygit.

perror avatar perror commented on April 27, 2024

It works like a charm now! :) Just did a go get -u lazygit and it was enough.
Thanks!

from lazygit.

SolitudeSF avatar SolitudeSF commented on April 27, 2024

you should revert to using sh instead of bash, unless you want to have hard dependency on bash. and from i can see you only use it as a command launcher so its redundant anyway.

from lazygit.

dawidd6 avatar dawidd6 commented on April 27, 2024

This issue seems to be resolved, tested on 16.04 after this referenced pull request merge.

from lazygit.

spin6lock avatar spin6lock commented on April 27, 2024

problem solved after update to latest version:) Thanks @jesseduffield !

from lazygit.

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.