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

oracle / opengrok / #3731

30 Nov 2023 04:39PM CUT coverage: 66.148% (-8.7%) from 74.811%
#3731

push

vladak
update Tomcat to 10.1.16

fixes #4492

38758 of 58593 relevant lines covered (66.15%)

0.66 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/AccuRevAnnotationParser.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) 2008, 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
 * handles parsing the output of the {@code accurev annotate} command
38
 * into an annotation object.
39
 */
40
public class AccuRevAnnotationParser implements Executor.StreamHandler {
41

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

44
    private static final Pattern ANNOTATION_PATTERN
×
45
            = Pattern.compile("^\\s+(\\d+.\\d+)\\s+(\\w+)");   // version, user
×
46

47
    /**
48
     * Store annotation created by processStream.
49
     */
50
    private final Annotation annotation;
51

52
    private final String fileName;
53

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

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

71
    @Override
72
    public void processStream(InputStream input) throws IOException {
73
        try (BufferedReader reader
×
74
                = new BufferedReader(new InputStreamReader(input))) {
75
            String line;
76
            int lineno = 0;
×
77
            try {
78
                while ((line = reader.readLine()) != null) {
×
79
                    ++lineno;
×
80
                    Matcher matcher = ANNOTATION_PATTERN.matcher(line);
×
81

82
                    if (matcher.find()) {
×
83
                        // On Windows machines version shows up as
84
                        // <number>\<number>. To get search annotation
85
                        // to work properly, need to flip '\' to '/'.
86
                        // This is a noop on Unix boxes.
87
                        String version = matcher.group(1).replace('\\', '/');
×
88
                        String author  = matcher.group(2);
×
89
                        annotation.addLine(version, author, true);
×
90
                    } else {
×
91
                        LOGGER.log(Level.WARNING,
×
92
                                "Did not find annotation in line {0} for ''{1}'': [{2}]",
93
                                new Object[]{lineno, this.fileName, line});
×
94
                    }
95
                }
×
96
            } catch (IOException e) {
×
97
                LOGGER.log(Level.WARNING,
×
98
                        String.format("Could not read annotations for '%s'", this.fileName), e);
×
99
            }
×
100
        }
101
    }
×
102
}
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

© 2025 Coveralls, Inc