• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oracle / opengrok / #3728

30 Nov 2023 04:39PM UTC coverage: 74.811% (-1.1%) from 75.91%
#3728

push

vladak
update Tomcat to 10.1.16

fixes #4492

43834 of 58593 relevant lines covered (74.81%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/opengrok-indexer/src/main/java/org/opengrok/indexer/history/BazaarAnnotationParser.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
/*
21
 * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
22
 */
23
package org.opengrok.indexer.history;
24

25
import java.io.BufferedReader;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.InputStreamReader;
29
import java.util.logging.Level;
30
import java.util.logging.Logger;
31
import java.util.regex.Matcher;
32
import java.util.regex.Pattern;
33
import org.opengrok.indexer.logger.LoggerFactory;
34
import org.opengrok.indexer.util.Executor;
35

36
/**
37
 * BazaarAnnotationParser handles parsing the output of the {@code bzr blame}
38
 * command into an annotation object.
39
 */
40
public class BazaarAnnotationParser implements Executor.StreamHandler {
41

42
    private static final Logger LOGGER = LoggerFactory.getLogger(BazaarAnnotationParser.class);
×
43

44
    /**
45
     * Store annotation created by processStream.
46
     */
47
    private final Annotation annotation;
48

49
    /**
50
     * Pattern used to extract author/revision.
51
     */
52
    private static final Pattern BLAME_PATTERN = Pattern.compile("^\\W*(\\S+)\\W+(\\S+).*$");
×
53

54
    private final String fileName;
55

56
    /**
57
     * @param fileName the name of the file being annotated
58
     */
59
    public BazaarAnnotationParser(String fileName) {
×
60
        annotation = new Annotation(fileName);
×
61
        this.fileName = fileName;
×
62
    }
×
63

64
    /**
65
     * Returns the annotation that has been created.
66
     *
67
     * @return annotation an annotation object
68
     */
69
    public Annotation getAnnotation() {
70
        return annotation;
×
71
    }
72

73
    @Override
74
    public void processStream(InputStream input) throws IOException {
75
        try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) {
×
76
            String line = "";
×
77
            int lineno = 0;
×
78
            Matcher matcher = BLAME_PATTERN.matcher(line);
×
79
            while ((line = in.readLine()) != null) {
×
80
                ++lineno;
×
81
                matcher.reset(line);
×
82
                if (matcher.find()) {
×
83
                    String rev = matcher.group(1);
×
84
                    String author = matcher.group(2).trim();
×
85
                    annotation.addLine(rev, author, true);
×
86
                } else {
×
87
                    LOGGER.log(Level.WARNING,
×
88
                            "Error: did not find annotation in line {0} for ''{1}'': [{2}]",
89
                            new Object[]{String.valueOf(lineno), this.fileName, line});
×
90
                }
91
            }
92
        }
93
    }
×
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc