[JIRA] (JENKINS-60509) Name column in Pull Request/Branch view should use number aware sorting

3 views
Skip to first unread message

rjfenton@mtu.edu (JIRA)

unread,
Dec 16, 2019, 1:05:04 PM12/16/19
to jenkinsc...@googlegroups.com
Ryan Fenton-Garcia created an issue
 
Jenkins / Improvement JENKINS-60509
Name column in Pull Request/Branch view should use number aware sorting
Issue Type: Improvement Improvement
Assignee: Unassigned
Attachments: Jenkins Sort Disconnect.PNG, Not the first PR.PNG
Components: branch-api-plugin
Created: 2019-12-16 18:04
Environment: Jenkins 2.209-SNAPSHOT (Built from commit 9368197)
Branch API plugin 2.5.5
Priority: Minor Minor
Reporter: Ryan Fenton-Garcia

I've been using Jenkins for a while and one of the things that's always bothered me is when sorting the list of recent PR's and seeing that the list is sorted in a way that is purely alphabetical. This usually results in something like PR-1046 sitting at the top of the list, with PR-1138 which is actually the latest PR sitting in the middle of the list after some weird break in numbers. I find it easiest to explain this with the screenshots below. 

The last couple of days, I've sort of made it my mission to attempt to fix this. I've implemented a number aware comparator so that when given a list: [foo100000, foo100010, foo800, goo, a, foo9000, foo], it is properly sorted as: [a, foo, foo800, foo9000, foo100000, foo100010, goo], but my issue is now, I have no idea what to actually do with it.

I looked at the branch-api-plugin and found the main MultiBranchProjectViewHolder.java which appears to have a MultiBranchProject (I'd assumed this is the project name or title thing at the top of the page in the screenshot), it also the ViewsTabBar (I'm assuming this is like the Branches, PR, tab selector thing), and then a List<View>. I had assumed the List<View> was the list I have pointed out in the screenshots and I reached down into core where I noticed View had this block of code:

    public static final Comparator<View> SORTER = new Comparator<View>() {
        public int compare(View lhs, View rhs) {
            return lhs.getViewName().compareTo(rhs.getViewName());
        }
    };

I tried to replace this with my custom comparator thinking it would sort the list as I expected, but in the end nothing happened.

I've done more digging this morning, found some .jelly files that look like maybe what I want to try modifying next, but at the end of the day I know nothing. Can anyone tell me what part of code creates the page I'm looking at or where I may want to look to start modifying the default sorting algorithm for these lists? 

TL;DR: I want to improve the default sorting algorithm for the lists of PR's in the branch-api plugin. Where should I look in core, or branch-api to make this happen?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

bitwiseman@gmail.com (JIRA)

unread,
Feb 10, 2020, 7:04:02 PM2/10/20
to jenkinsc...@googlegroups.com
Liam Newman commented on Improvement JENKINS-60509
 
Re: Name column in Pull Request/Branch view should use number aware sorting

@Ryan Fenton-Garcia
Thanks for looking into how to fix this. I'm not sure I can help, but I believe you are in the right area. Could you put up a PR of what you've done and we can discuss from there?

Reply all
Reply to author
Forward
0 new messages