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

oracle / opengrok / #3658

25 Oct 2023 12:46PM UTC coverage: 66.025% (-9.8%) from 75.792%
#3658

push

web-flow
Handle history cache failures (#4456)

fixes #747

84 of 84 new or added lines in 4 files covered. (100.0%)

38700 of 58614 relevant lines covered (66.03%)

0.66 hits per line

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

34.78
/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RCSAnnotationParser.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 org.opengrok.indexer.logger.LoggerFactory;
26
import org.opengrok.indexer.util.Executor;
27

28
import java.io.IOException;
29
import java.io.BufferedReader;
30
import java.io.File;
31
import java.io.InputStream;
32
import java.io.InputStreamReader;
33
import java.util.logging.Level;
34
import java.util.logging.Logger;
35
import java.util.regex.Matcher;
36
import java.util.regex.Pattern;
37

38
public class RCSAnnotationParser implements Executor.StreamHandler {
39
    private static final Logger LOGGER = LoggerFactory.getLogger(RCSAnnotationParser.class);
1✔
40

41
    private Annotation annotation = null;
1✔
42
    private final File file;
43

44
    /**
45
     * Pattern used to extract author/revision from {@code blame}.
46
     */
47
    private static final Pattern ANNOTATION_PATTERN
1✔
48
            = Pattern.compile("^([\\d\\.]+)\\s*\\((\\S+)\\s*\\S+\\): ");
1✔
49

50
    RCSAnnotationParser(File file) {
1✔
51
        this.file = file;
1✔
52
    }
1✔
53

54
    @Override
55
    public void processStream(InputStream input) throws IOException {
56
        annotation = new Annotation(file.getName());
×
57
        String line;
58
        int lineno = 0;
×
59
        Matcher matcher = ANNOTATION_PATTERN.matcher("");
×
60

61
        try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) {
×
62
            while ((line = in.readLine()) != null) {
×
63
                ++lineno;
×
64
                matcher.reset(line);
×
65
                if (matcher.find()) {
×
66
                    String rev = matcher.group(1);
×
67
                    String author = matcher.group(2);
×
68
                    annotation.addLine(rev, author, true);
×
69
                } else {
×
70
                    LOGGER.log(Level.WARNING,
×
71
                            "Error: did not find annotation in line {0} for ''{1}'': [{2}]",
72
                            new Object[]{lineno, this.file, line});
×
73
                }
74
            }
75
        }
76
    }
×
77

78
    Annotation getAnnotation() {
79
        return this.annotation;
1✔
80
    }
81
}
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