]> source.dussan.org Git - gitblit.git/commitdiff
Fix TicketModel modList bug when a field was set multiple times 30/30/1
authorJames Moger <james.moger@gitblit.com>
Thu, 13 Mar 2014 02:25:52 +0000 (22:25 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 13 Mar 2014 02:25:52 +0000 (22:25 -0400)
src/main/java/com/gitblit/git/PatchsetReceivePack.java
src/main/java/com/gitblit/models/TicketModel.java

index d3d0b1df46df8123881cb8e281dbf6fde06c5c43..bdba8b9172554c97d4491161b5808289d3cb0ca3 100644 (file)
@@ -163,11 +163,11 @@ public class PatchsetReceivePack extends GitblitReceivePack {
 \r
        /** Extracts the ticket id from the ref name */\r
        private long getTicketId(String refName) {\r
+               if (refName.indexOf('%') > -1) {\r
+                       refName = refName.substring(0, refName.indexOf('%'));\r
+               }\r
                if (refName.startsWith(Constants.R_FOR)) {\r
                        String ref = refName.substring(Constants.R_FOR.length());\r
-                       if (ref.indexOf('%') > -1) {\r
-                               ref = ref.substring(0, ref.indexOf('%'));\r
-                       }\r
                        try {\r
                                return Long.parseLong(ref);\r
                        } catch (Exception e) {\r
index fa09ec597bcd5e100e3e498eaffbe52968c8be7a..aced6d7822131efff724ac9f3448077dae4380ae 100644 (file)
@@ -785,7 +785,21 @@ public class TicketModel implements Serializable, Comparable<TicketModel> {
                        for (String item : items) {
                                list.add(prefix + item);
                        }
-                       setField(field, join(list, ","));
+                       if (hasField(field)) {
+                               String flat = getString(field);
+                               if (isEmpty(flat)) {
+                                       // field is empty, use this list
+                                       setField(field, join(list, ","));
+                               } else {
+                                       // merge this list into the existing field list
+                                       Set<String> set = new TreeSet<String>(Arrays.asList(flat.split(",")));
+                                       set.addAll(list);
+                                       setField(field, join(set, ","));
+                               }
+                       } else {
+                               // does not have a list for this field
+                               setField(field, join(list, ","));
+                       }
                }
 
                public String getId() {