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

oracle / opengrok / #3691

09 Nov 2023 04:15PM UTC coverage: 74.721% (+8.6%) from 66.08%
#3691

push

web-flow
avoid annotations for binary files (#4476)

fixes #4473

6 of 13 new or added lines in 4 files covered. (46.15%)

258 existing lines in 28 files now uncovered.

43797 of 58614 relevant lines covered (74.72%)

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/SCCSRepositoryAnnotationParser.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, 2023, 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.File;
27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.io.InputStreamReader;
30
import java.util.Map;
31
import java.util.logging.Level;
32
import java.util.logging.Logger;
33
import java.util.regex.Matcher;
34
import java.util.regex.Pattern;
35
import org.opengrok.indexer.logger.LoggerFactory;
36
import org.opengrok.indexer.util.Executor;
37

38
/**
39
 * handles parsing into Annotation object.
40
 */
41
public class SCCSRepositoryAnnotationParser implements Executor.StreamHandler {
42
    private static final Logger LOGGER = LoggerFactory.getLogger(SCCSRepositoryAnnotationParser.class);
×
43

44
    /**
45
     * Store annotation created by {@link #processStream(InputStream)}.
46
     */
47
    private final Annotation annotation;
48

49
    private final Map<String, String> authors;
50

51
    private final File file;
52

53
    /**
54
     * Pattern used to extract revision from the {@code sccs get} command.
55
     */
56
    private static final Pattern ANNOTATION_PATTERN = Pattern.compile("^([\\d.]+)\\s+");
×
57

58
    SCCSRepositoryAnnotationParser(File file, Map<String, String> authors) {
×
NEW
59
        this.file = file;
×
60
        this.annotation = new Annotation(file.getName());
×
61
        this.authors = authors;
×
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 {
NEW
75
        try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) {
×
76
            String line;
77
            int lineno = 0;
×
78
            while ((line = in.readLine()) != null) {
×
79
                ++lineno;
×
80
                Matcher matcher = ANNOTATION_PATTERN.matcher(line);
×
81
                if (matcher.find()) {
×
82
                    String rev = matcher.group(1);
×
83
                    String author = authors.get(rev);
×
84
                    if (author == null) {
×
85
                        author = "unknown";
×
86
                    }
87

88
                    annotation.addLine(rev, author, true);
×
89
                } else {
×
90
                    LOGGER.log(Level.SEVERE,
×
91
                            "Error: did not find annotations in line {0} for ''{2}'': [{1}]",
NEW
92
                            new Object[]{lineno, line, file});
×
93
                }
94
            }
×
95
        }
96
    }
×
97
}
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