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

jreleaser / jreleaser / #477

04 Apr 2025 05:53PM UTC coverage: 35.124% (-5.1%) from 40.183%
#477

push

github

aalmiray
fix(deploy): Add missing Forgejo messages

Related to #1842

18210 of 51845 relevant lines covered (35.12%)

0.35 hits per line

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

80.0
/api/jreleaser-model-api/src/main/java/org/jreleaser/model/Active.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.model;
19

20
import java.util.Locale;
21
import java.util.function.Predicate;
22

23
import static org.jreleaser.util.StringUtils.isBlank;
24

25
/**
26
 * @author Andres Almiray
27
 * @since 0.2.0
28
 */
29
public enum Active {
1✔
30
    ALWAYS(project -> true),
1✔
31
    NEVER(project -> false),
1✔
32
    RELEASE(Releaseable::isRelease),
1✔
33
    PRERELEASE(project -> true),
1✔
34
    RELEASE_PRERELEASE(Releaseable::isRelease),
1✔
35
    SNAPSHOT(r -> !r.isRelease());
1✔
36

37
    private final Predicate<Releaseable> test;
38

39
    Active(Predicate<Releaseable> test) {
1✔
40
        this.test = test;
1✔
41
    }
1✔
42

43
    public boolean check(Releaseable project) {
44
        return test.test(project);
1✔
45
    }
46

47
    public boolean check(Releaseable project, Prereleaseable service) {
48
        boolean p = this.test.test(project);
×
49
        if (p && (this == PRERELEASE || this == RELEASE_PRERELEASE)) return service.isPrerelease();
×
50
        return p;
×
51
    }
52

53
    public String formatted() {
54
        return name().toLowerCase(Locale.ENGLISH);
×
55
    }
56

57
    public static Active of(String str) {
58
        if (isBlank(str)) return null;
1✔
59
        return Active.valueOf(str.toUpperCase(Locale.ENGLISH).trim()
1✔
60
            .replace("+", "_")
1✔
61
            .replace("-", "_")
1✔
62
            .replace(" ", "_"));
1✔
63
    }
64

65
    public interface Releaseable {
66
        boolean isRelease();
67
    }
68

69
    public interface Prereleaseable {
70
        boolean isPrerelease();
71
    }
72
}
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