LCOV - code coverage report
Current view: top level - server/config - TrackingFooter.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 11 12 91.7 %
Date: 2022-11-19 15:00:39 Functions: 4 5 80.0 %

          Line data    Source code
       1             : // Copyright (C) 2010 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.config;
      16             : 
      17             : import java.util.regex.Pattern;
      18             : import java.util.regex.PatternSyntaxException;
      19             : import org.eclipse.jgit.revwalk.FooterKey;
      20             : import org.eclipse.jgit.revwalk.FooterLine;
      21             : 
      22             : /** Tracking entry in the configuration file */
      23             : public class TrackingFooter {
      24             :   private final FooterKey key;
      25             :   private final Pattern match;
      26             :   private final String system;
      27             : 
      28          11 :   public TrackingFooter(String f, String m, String s) throws PatternSyntaxException {
      29          11 :     f = f.trim();
      30          11 :     if (f.endsWith(":")) {
      31          11 :       f = f.substring(0, f.length() - 1);
      32             :     }
      33          11 :     this.key = new FooterKey(f);
      34          11 :     this.match = Pattern.compile(m.trim());
      35          11 :     this.system = s.trim();
      36          11 :   }
      37             : 
      38             :   /** {@link FooterKey} to match in the commit message */
      39             :   public FooterKey footerKey() {
      40           7 :     return key;
      41             :   }
      42             : 
      43             :   /** Regex for parsing out external tracking id from {@link FooterLine} */
      44             :   public Pattern match() {
      45           5 :     return match;
      46             :   }
      47             : 
      48             :   /** Name of the remote tracking system */
      49             :   public String system() {
      50           5 :     return system;
      51             :   }
      52             : 
      53             :   @Override
      54             :   public String toString() {
      55           0 :     return "footer = " + key.getName() + ", match = " + match.pattern() + ", system = " + system;
      56             :   }
      57             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750