Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 6310 Provide ability to sort/order branches and tags #8427

Merged
merged 2 commits into from Sep 13, 2020

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Aug 29, 2020

Fixes #6310
Fixes #7456
Fixes #8301
Fixes #8427
Resolves #7472
Closes #4869
Closes #8309 as obsolete

Proposed changes

  • Provide ability to sort/order branches

Restore the functionality (albeit improved) removed in 9c7c76f.

Allow to either defer sorting to git (i.e. sort by Default) which is either implicit, or configured via git config branch.sort.

Alternatively expose the following sort by options:

  • authordate
  • committerdate
  • creatordate
  • taggerdate
  • refname
  • objectsize
  • upstream

For user-specified sort, allow to select ascending or descending order (default: desc).

Git v2.19+ is required to facilitate the above, hence bump in the min version.

The sort configuration applies to both the left panel and the branches dropdown in the toolstrip.

Screenshots

After

  • Settings:
    image
    image

  • The left panel:
    image

Test methodology

  • manual
  • added few unit tests

✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned RussKie Aug 29, 2020
@RussKie RussKie force-pushed the fix_6310_sort_branches branch 4 times, most recently from b051ec4 to 1fa75cd Compare September 1, 2020 07:39
@codecov
Copy link

codecov bot commented Sep 1, 2020

Codecov Report

Merging #8427 into master will increase coverage by 0.10%.
The diff coverage is 78.15%.

@@            Coverage Diff             @@
##           master    #8427      +/-   ##
==========================================
+ Coverage   53.00%   53.11%   +0.10%     
==========================================
  Files         877      881       +4     
  Lines       62128    62366     +238     
  Branches    11332    11351      +19     
==========================================
+ Hits        32934    33127     +193     
- Misses      26533    26567      +34     
- Partials     2661     2672      +11     
Flag Coverage Δ
#production 41.02% <64.50%> (+0.04%) ⬆️
#tests 94.31% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@RussKie
Copy link
Member Author

RussKie commented Sep 1, 2020

@msftbot merge in 48 hours

@ghost ghost added the status: auto merge label Sep 1, 2020
@gitextensions gitextensions deleted a comment Sep 1, 2020
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brief, review, brief testing. Some comments, considered blocking auto merge

GitCommands/Git/GitModule.cs Outdated Show resolved Hide resolved
GitCommands/Git/GitModule.cs Outdated Show resolved Hide resolved
GitCommands/Git/GitVersion.cs Outdated Show resolved Hide resolved
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git show-ref do not have --sort option
I cannot trigger the use of --sort to GetRefsCmd() with sort though

@ghost ghost added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Sep 2, 2020
@gerhardol
Copy link
Member

@msftbot forget what I just told you

@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Sep 4, 2020
@RussKie RussKie marked this pull request as draft September 4, 2020 12:10
@RussKie RussKie marked this pull request as ready for review September 7, 2020 01:55
@RussKie
Copy link
Member Author

RussKie commented Sep 7, 2020

Outstanding: resolution of the context menu placement for the Tags node. Judging by incoming PRs looks like @ivangrek has significantly better understanding of this part 😁.

@RussKie RussKie changed the title Fix 6310 Provide ability to sort/order branches Fix 6310 Provide ability to sort/order branches and tags Sep 7, 2020
@RussKie RussKie added the area: left-panel Issues related to the Left Panel label Sep 7, 2020
@ghost
Copy link

ghost commented Sep 9, 2020

Is this the correct state?

image

image

@RussKie
Copy link
Member Author

RussKie commented Sep 10, 2020

Is this the correct state?

Champion! You're clearly a better tester than I am 🙇‍♂️ No, this is definitely something I didn't anticipate, and now I need to think of it more.
Though this should go into #8414, this PR is about sorting.

@RussKie RussKie force-pushed the fix_6310_sort_branches branch 4 times, most recently from 6a00136 to 04617c5 Compare September 11, 2020 12:15
@RussKie
Copy link
Member Author

RussKie commented Sep 11, 2020

@gerhardol I'd appreciate your re-review, I believe your points are addressed.

Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly looked at GitModule changes, a few comments only.
Briefly looked at the rest, briefly tested.
I suggest it is merged, but not deep enough review to formally approve.

{ sortBy != GitRefsSortBy.Default, GetSortCriteria(tags, sortBy, sortOrder), string.Empty },
format,
{ branches, "refs/heads/", string.Empty },
{ branches && tags, "refs/remotes/", string.Empty },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related issue #6044, this PR shows more clearly the special handling for remotes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing me to this. This API can do with quite a bit of improvement, but I didn't want to change to much in the context of this PR. I will do a follow up improvement later.

// Else
// format = %(*objectname) %(*refname) // i.e. info from a referenced commit
// End
format = @"--format=""%(if)%(authordate)%(then)%(objectname) %(refname)%(else)%(*objectname) %(*refname)%(end)""";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes #8301 replacing PR #8309
This assumes the comment in #8301 (comment) is OK: non-dereferenced tags are not used in the application

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, we can certainly look at this as a follow up 👍

GitCommands/Git/GitModule.cs Outdated Show resolved Hide resolved
GitCommands/Git/Commands/GitCommandHelpers.cs Show resolved Hide resolved
@RussKie
Copy link
Member Author

RussKie commented Sep 13, 2020

I suggest it is merged, but not deep enough review to formally approve.

Taking this as an approval. Feel free to cancel the auto-merge, if it isn't so.

@ghost ghost added the status: auto merge label Sep 13, 2020
@ghost
Copy link

ghost commented Sep 13, 2020

Hello @RussKie!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @gerhardol
  • I won't merge this pull request until after the UTC date Mon, 14 Sep 2020 02:43:49 GMT, which is in 1 day

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@gitextensions gitextensions deleted a comment Sep 13, 2020
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest it is merged, but not deep enough review to formally approve.

Taking this as an approval. Feel free to cancel the auto-merge, if it isn't so.

Approval to merge, but incomplete review, focusing on GetRefs() that I found to be important.
More of browsing the remaining, I could understand what I looked at and no obvious problems.
There are a few discussion points still, can be discussed separately.

Approving with the limitations in the review stated above.

Restore the functionality (albeit improved) removed in 9c7c76f.

Allow to either defer sorting to git (i.e. sort by Default) which is
either implicit, or configured via `git config branch.sort`.

Alternatively expose the following sort by options:
- authordate
- committerdate
- creatordate
- taggerdate
- refname
- objectsize
- upstream

For user-specified sort, allow to select ascending or descending order (default: desc).

Git v2.19+ is required to facilitate sort by default, hence bump in the min version.
Update the recommended version to 2.28.0 while we are at it.

The sort configuration applies to both the left panel and the branches
dropdown in the toolstrip.

Fixes gitextensions#6310
Fixes gitextensions#8301
Resolves gitextensions#7472
Closes gitextensions#4869
Closes gitextensions#8309
@RussKie RussKie merged commit 2d52621 into gitextensions:master Sep 13, 2020
@RussKie RussKie deleted the fix_6310_sort_branches branch September 13, 2020 10:39
@ghost ghost added this to the 4.0 milestone Sep 13, 2020
RussKie added a commit to RussKie/gitextensions that referenced this pull request Oct 2, 2020
@jrfnl
Copy link

jrfnl commented Apr 26, 2021

@RussKie Thank you!!!! ❤️ Been missing this a lot!

Only question I have is: is there a way to sort alphanumerically, but case insensitively ? Might be possible already, but I haven't figured out how to do it.

@RussKie
Copy link
Member Author

RussKie commented Apr 26, 2021 via email

@RussKie
Copy link
Member Author

RussKie commented Apr 27, 2021

Related: #8508

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: left-panel Issues related to the Left Panel status: auto merge
Projects
None yet
3 participants