Giter Site home page Giter Site logo

Comments (10)

spacewander avatar spacewander commented on June 10, 2024 1

It seems that it is because the default branch is main? There is a check in the cmd:

branches=$(git branch --no-color --merged | grep -vE "^(\*|\+)" | grep -v "$(git_extra_default_branch)" | grep -v svn)

Either you can configure the default branch to master, or the default branch detection is not correct.

from git-extras.

hyperupcall avatar hyperupcall commented on June 10, 2024 1

@spacewander I think it would be simple and effective to skip the deletion of branches with hardcoded values of master, main, trunk, default, development, stable, release, and production. I think that should detect 99% of cases, and will ignore some useful branches that may not be the default branch of any remote. To prevent confusion over the change of behavior, I think a warning should be emitted if we ignore a branch.

We can also read the config value for the default init branch and add that.

Indeed, I suggest the following approach

If there's a single remote use it
If multiple, only look up origin, then maybe upstream.
If not possible look at the existing init default branch

I agree with @spacewander, although it is a good heuristic, I think there is too much uncertainty around it and it will invariably do different things, even on the same computer. I for one, always use me instead of origin.

Another idea is to loop over all remotes, and add any of their default branches to the ignore list. I am not completely certain that it will not introduce many false positives.

from git-extras.

bric3 avatar bric3 commented on June 10, 2024

It seems the git_extra_default_branch help function work by looking at configured values or environment variables, if none are present this function falls back to main.

git_extra_default_branch() {
local extras_default_branch init_default_branch
extras_default_branch=$(git config --get git-extras.default-branch)
init_default_branch=$(git config --get init.defaultBranch)
if [ -n "$extras_default_branch" ]; then
echo "$extras_default_branch"
elif [ -n "$init_default_branch" ]; then
echo "$init_default_branch"
else
echo "main"
fi
}

from git-extras.

spacewander avatar spacewander commented on June 10, 2024

So you can configure the default branch to master, if you are using it as the default branch.

from git-extras.

bric3 avatar bric3 commented on June 10, 2024

Yes but wouldn't that be better if git-extras discover this automatically, using the commands above ?

from git-extras.

spacewander avatar spacewander commented on June 10, 2024

Yes but wouldn't that be better if git-extras discover this automatically, using the commands above ?

Would you happen to have any suggestions? The git_extra_default_branch is just reading the configured value.

from git-extras.

bric3 avatar bric3 commented on June 10, 2024

@spacewander Sorry for the late reply. Yes I think what I proposed in the top message could help resolve the default branch :

git rev-parse --abbrev-ref ${the_remote}/HEAD

from git-extras.

spacewander avatar spacewander commented on June 10, 2024

@spacewander Sorry for the late reply. Yes I think what I proposed in the top message could help resolve the default branch :

git rev-parse --abbrev-ref ${the_remote}/HEAD

Err... But there may be multiple remotes.

from git-extras.

bric3 avatar bric3 commented on June 10, 2024

Indeed, I suggest the following approach

  1. If there's a single remote use it
  2. If multiple, only look up origin, then maybe upstream.
  3. If not possible look at the existing init default branch

from git-extras.

spacewander avatar spacewander commented on June 10, 2024

Indeed, I suggest the following approach

  1. If there's a single remote use it
  2. If multiple, only look up origin, then maybe upstream.
  3. If not possible look at the existing init default branch

It seems too complex to me, which may introduce strange behavior. For example, the git-extras in my local machine has two remotes:

origin	[email protected]:spacewander/git-extras (fetch)
origin	[email protected]:spacewander/git-extras (push)
own	[email protected]:tj/git-extras (fetch)
own	[email protected]:tj/git-extras (push)

The origin(https://github.com/spacewander/git-extras) 's default branch is master, while the own(https://github.com/tj/git-extras) 's default branch is main.

The guess can't guarantee it's 100% correct.

@hyperupcall @vanpipy
What about your opinion?

from git-extras.

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.