Giter Site home page Giter Site logo

Comments (5)

sjaveed avatar sjaveed commented on July 20, 2024

Nice! I've been using git symbolic-ref in my own PS1 which is a lot dumber than git-radar so this should come in handy for me. Thanks @jart!

Edit: bonus points for the ï in naïve :-)

from git-radar.

zx8 avatar zx8 commented on July 20, 2024

Disclaimer: I'm not a git-radar user nor do I have problems with the responsiveness of my prompt, I was just browsing the project's issues out of curiosity after following a link from a friend!

Anyway, this bit needs to be revised, because / is a valid character in a branch name:

jartps1_gitbranch="${head##*/}"

Example:

$ head=release/1.0
$ echo "${head##*/}"
1.0

from git-radar.

jart avatar jart commented on July 20, 2024

@zx8 Wow thanks for finding that bug. I updated the code in my original comment. PTAL?

I'm not 100% sure what the best approach is, since I don't know everything that could be contained in that file. So I tried to pick the safest heuristic possible.

from git-radar.

zx8 avatar zx8 commented on July 20, 2024

Hmm, think you've overcomplicated it a bit, how about something simple like this:

$ h=refs/heads/release/1/2/3
$ echo ${h##refs/heads/}
release/1/2/3

from git-radar.

jart avatar jart commented on July 20, 2024

@zx8 The ## syntax wouldn't work since the HEAD file contains ref: refs/heads/branch on my end. I guess I could just say ${h##ref: refs/heads/} though. But that would be more fragile without the simpler fallback. I imagine that HEAD file can contain all sorts of things. Like if you checkout a SHA1 ID, it won't have the ref:blahblah prefix; it'll just contain the hash.

from git-radar.

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.