Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-60509

Name column in Pull Request/Branch view should use number aware sorting



    • Improvement
    • Resolution: Unresolved
    • Minor
    • branch-api-plugin
    • None
    • Jenkins 2.209-SNAPSHOT (Built from commit 9368197)
      Branch API plugin 2.5.5


      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?




            Unassigned Unassigned
            bustylolichan Ryan Fenton-Garcia
            1 Vote for this issue
            4 Start watching this issue