Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/test/resources"]
path = src/test/resources
url = git@github.com:git-commit-id/git-test-resources.git
url = https://github.com/git-commit-id/git-test-resources.git
24 changes: 4 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@
<assertj.version>3.27.7</assertj.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<optional>true</optional>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -239,15 +228,10 @@
<artifactId>org.eclipse.jgit.ssh.jsch</artifactId>
<version>${jgit.version}</version>
</dependency>
<!-- Joda Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>nu.studer</groupId>
Expand Down Expand Up @@ -314,7 +298,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.17</version>
<version>1.7.36</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/pl/project13/core/GitCommitIdPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

package pl.project13.core;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import pl.project13.core.cibuild.BuildServerDataProvider;
import pl.project13.core.git.GitDescribeConfig;
import pl.project13.core.log.LogInterface;
import pl.project13.core.util.BuildFileChangeListener;
import pl.project13.core.util.GitDirLocator;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Path;
Expand Down Expand Up @@ -55,14 +55,14 @@ default Map<String, String> getSystemEnv() {
/**
* @return Logging Interface
*/
@Nonnull
@NonNull
LogInterface getLogInterface();

/**
* @return The date format to be used for any dates exported by this plugin.
* It should be a valid {@link SimpleDateFormat} string.
*/
@Nonnull
@NonNull
String getDateFormat();

/**
Expand All @@ -74,15 +74,15 @@ default Map<String, String> getSystemEnv() {
*
* @return The timezone used in the date format of dates exported by this plugin.
*/
@Nonnull
@NonNull
String getDateFormatTimeZone();

/**
* The prefix to expose the properties on. For example {@code 'git'} would allow you to access {@code ${git.branch}}.
*
* @return The prefix to expose the properties on.
*/
@Nonnull
@NonNull
String getPrefixDot();

/**
Expand Down Expand Up @@ -297,7 +297,7 @@ default Map<String, String> getSystemEnv() {

protected static final Pattern allowedCharactersForEvaluateOnCommit = Pattern.compile("[a-zA-Z0-9\\_\\-\\^\\/\\.]+");

public static void runPlugin(@Nonnull Callback cb, @Nullable Properties contextProperties) throws GitCommitIdExecutionException {
public static void runPlugin(@NonNull Callback cb, @Nullable Properties contextProperties) throws GitCommitIdExecutionException {
PropertiesFilterer propertiesFilterer = new PropertiesFilterer(cb.getLogInterface());

// The properties we store our data in and then expose them.
Expand Down Expand Up @@ -334,7 +334,7 @@ public static void runPlugin(@Nonnull Callback cb, @Nullable Properties contextP
cb.performPublishToAllSystemEnvironments(properties);
}

protected static void loadBuildData(@Nonnull Callback cb, @Nonnull Properties properties) throws GitCommitIdExecutionException {
protected static void loadBuildData(@NonNull Callback cb, @NonNull Properties properties) throws GitCommitIdExecutionException {
Map<String, Supplier<String>> additionalProperties = Collections.singletonMap(
GitCommitPropertyConstant.BUILD_VERSION, cb.supplyProjectVersion());
BuildServerDataProvider buildServerDataProvider = BuildServerDataProvider.getBuildServerProvider(
Expand All @@ -349,7 +349,7 @@ protected static void loadBuildData(@Nonnull Callback cb, @Nonnull Properties pr
buildServerDataProvider.loadBuildData(properties, cb.getReproducibleBuildOutputTimestamp());
}

protected static void loadGitData(@Nonnull Callback cb, @Nonnull Properties properties) throws GitCommitIdExecutionException {
protected static void loadGitData(@NonNull Callback cb, @NonNull Properties properties) throws GitCommitIdExecutionException {
String evaluateOnCommit = cb.getEvaluateOnCommit();
if ((evaluateOnCommit == null) || !allowedCharactersForEvaluateOnCommit.matcher(evaluateOnCommit).matches()) {
throw new GitCommitIdExecutionException("suspicious argument for evaluateOnCommit, aborting execution!");
Expand All @@ -375,9 +375,9 @@ protected static void loadGitData(@Nonnull Callback cb, @Nonnull Properties prop
}

private static void loadGitDataWithNativeGit(
@Nonnull Callback cb,
@Nonnull File dotGitDirectory,
@Nonnull Properties properties) throws GitCommitIdExecutionException {
@NonNull Callback cb,
@NonNull File dotGitDirectory,
@NonNull Properties properties) throws GitCommitIdExecutionException {
GitDataProvider nativeGitProvider = NativeGitProvider
.on(dotGitDirectory, cb.getNativeGitTimeoutInMs(), cb.getLogInterface());

Expand All @@ -387,9 +387,9 @@ private static void loadGitDataWithNativeGit(
}

private static void loadGitDataWithJGit(
@Nonnull Callback cb,
@Nonnull File dotGitDirectory,
@Nonnull Properties properties) throws GitCommitIdExecutionException {
@NonNull Callback cb,
@NonNull File dotGitDirectory,
@NonNull Properties properties) throws GitCommitIdExecutionException {
GitDataProvider jGitProvider = JGitProvider
.on(dotGitDirectory, cb.getLogInterface());

Expand All @@ -399,9 +399,9 @@ private static void loadGitDataWithJGit(
}

private static void configureCommonProvider(
@Nonnull GitDataProvider provider,
@Nonnull Callback cb,
@Nonnull File dotGitDirectory) {
@NonNull GitDataProvider provider,
@NonNull Callback cb,
@NonNull File dotGitDirectory) {
provider
.setPrefixDot(cb.getPrefixDot())
.setAbbrevLength(cb.getAbbrevLength())
Expand All @@ -425,7 +425,7 @@ private static void configureCommonProvider(
* Returns null if the project directory is not within the repository or if resolution fails.
*/
@Nullable
private static String resolveRelativeModulePath(@Nonnull Callback cb, @Nonnull File dotGitDirectory) {
private static String resolveRelativeModulePath(@NonNull Callback cb, @NonNull File dotGitDirectory) {
try {
// Determine repository work tree
// If dotGitDirectory is named ".git", the work tree is its parent
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/pl/project13/core/GitDataProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package pl.project13.core;

import org.jspecify.annotations.NonNull;
import pl.project13.core.git.GitDescribeConfig;
import pl.project13.core.cibuild.BuildServerDataProvider;
import pl.project13.core.cibuild.UnknownBuildServerData;
import pl.project13.core.log.LogInterface;
import pl.project13.core.util.PropertyManager;

import javax.annotation.Nonnull;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
Expand All @@ -44,7 +44,7 @@ public abstract class GitDataProvider implements GitProvider {
/**
* Logging provider which will be used to log events.
*/
@Nonnull
@NonNull
protected final LogInterface log;

/**
Expand Down Expand Up @@ -126,7 +126,7 @@ public abstract class GitDataProvider implements GitProvider {
* Constructor to encapsulates all references required to dertermine all git-data.
* @param log logging provider which will be used to log events
*/
public GitDataProvider(@Nonnull LogInterface log) {
public GitDataProvider(@NonNull LogInterface log) {
this.log = log;
}

Expand Down Expand Up @@ -268,7 +268,7 @@ public GitDataProvider setPathFilter(String pathFilter) {
* @param properties The Properties-Set that should be enriched by the generated one.
* @throws GitCommitIdExecutionException In case any problem occurred during loading of the properties from the git repository.
*/
protected void loadGitData(@Nonnull String evaluateOnCommit, @Nonnull Map<String,String> env, @Nonnull Properties properties) throws GitCommitIdExecutionException {
protected void loadGitData(@NonNull String evaluateOnCommit, @NonNull Map<String,String> env, @NonNull Properties properties) throws GitCommitIdExecutionException {
this.evaluateOnCommit = evaluateOnCommit;
init();
// git.user.name
Expand Down Expand Up @@ -337,7 +337,7 @@ protected void loadGitData(@Nonnull String evaluateOnCommit, @Nonnull Map<String
}
}

private void maybePutGitDescribe(@Nonnull Properties properties) throws GitCommitIdExecutionException {
private void maybePutGitDescribe(@NonNull Properties properties) throws GitCommitIdExecutionException {
boolean isGitDescribeOptOutByDefault = (gitDescribe == null);
boolean isGitDescribeOptOutByConfiguration = (gitDescribe != null && !gitDescribe.isSkip());

Expand All @@ -346,7 +346,7 @@ private void maybePutGitDescribe(@Nonnull Properties properties) throws GitCommi
}
}

protected void loadShortDescribe(@Nonnull Properties properties) throws GitCommitIdExecutionException {
protected void loadShortDescribe(@NonNull Properties properties) throws GitCommitIdExecutionException {
//removes git hash part from describe
String commitDescribe = properties.getProperty(prefixDot + GitCommitPropertyConstant.COMMIT_DESCRIBE);

Expand Down Expand Up @@ -382,7 +382,7 @@ void validateAbbrevLength(int abbrevLength) throws GitCommitIdExecutionException
* @return results of getBranchName() or, if in Jenkins/Hudson, value of GIT_BRANCH
* @throws GitCommitIdExecutionException the branch name could not be determined
*/
protected String determineBranchName(@Nonnull Map<String, String> env) throws GitCommitIdExecutionException {
protected String determineBranchName(@NonNull Map<String, String> env) throws GitCommitIdExecutionException {
BuildServerDataProvider buildServerDataProvider = BuildServerDataProvider.getBuildServerProvider(env, log);
if (useBranchNameFromBuildEnvironment && !(buildServerDataProvider instanceof UnknownBuildServerData)) {
String branchName = buildServerDataProvider.getBuildBranch();
Expand All @@ -404,7 +404,7 @@ protected SimpleDateFormat getSimpleDateFormatWithTimeZone() {
return smf;
}

protected void maybePut(@Nonnull Properties properties, String key, SupplierEx<String> value)
protected void maybePut(@NonNull Properties properties, String key, SupplierEx<String> value)
throws GitCommitIdExecutionException {
String keyWithPrefix = prefixDot + key;
if (properties.stringPropertyNames().contains(keyWithPrefix)) {
Expand Down Expand Up @@ -531,4 +531,4 @@ protected String stripCredentialsFromOriginUrl(String gitRemoteString) throws Gi
return "";
}
}
}
}
15 changes: 7 additions & 8 deletions src/main/java/pl/project13/core/JGitProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.util.FS;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import pl.project13.core.jgit.DescribeResult;
import pl.project13.core.jgit.JGitCommon;
import pl.project13.core.jgit.DescribeCommand;
Expand All @@ -40,9 +42,6 @@

import org.eclipse.jgit.storage.file.WindowCacheConfig;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class JGitProvider extends GitDataProvider {

private File dotGitDirectory;
Expand All @@ -52,12 +51,12 @@ public class JGitProvider extends GitDataProvider {
private RevCommit evalCommit;
private JGitCommon jGitCommon;

@Nonnull
public static JGitProvider on(@Nonnull File dotGitDirectory, @Nonnull LogInterface log) {
@NonNull
public static JGitProvider on(@NonNull File dotGitDirectory, @NonNull LogInterface log) {
return new JGitProvider(dotGitDirectory, log);
}

JGitProvider(@Nonnull File dotGitDirectory, @Nonnull LogInterface log) {
JGitProvider(@NonNull File dotGitDirectory, @NonNull LogInterface log) {
super(log);
this.dotGitDirectory = dotGitDirectory;
FS.FileStoreAttributes.setBackground(true);
Expand Down Expand Up @@ -130,7 +129,7 @@ public void prepareGitToExtractMoreDetailedRepoInformation() throws GitCommitIdE
* Returns the commit hash or null if no commits found.
*/
@Nullable
private String findLatestCommitForPath(@Nonnull String path) throws GitCommitIdExecutionException {
private String findLatestCommitForPath(@NonNull String path) throws GitCommitIdExecutionException {
try {
ObjectId start = git.resolve(evaluateOnCommit);
if (start == null) {
Expand Down Expand Up @@ -412,7 +411,7 @@ private String getAbbrevCommitId(ObjectReader objectReader, RevCommit headCommit
}
}

@Nonnull
@NonNull
private Repository getGitRepository() throws GitCommitIdExecutionException {
Repository repository;

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/pl/project13/core/NativeGitProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import static java.lang.String.format;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import pl.project13.core.git.GitDescribeConfig;
import pl.project13.core.log.LogInterface;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import java.io.*;
import java.text.SimpleDateFormat;
Expand All @@ -44,12 +44,12 @@ public class NativeGitProvider extends GitDataProvider {

final File canonical;

@Nonnull
public static NativeGitProvider on(@Nonnull File dotGitDirectory, long nativeGitTimeoutInMs, @Nonnull LogInterface log) {
@NonNull
public static NativeGitProvider on(@NonNull File dotGitDirectory, long nativeGitTimeoutInMs, @NonNull LogInterface log) {
return new NativeGitProvider(dotGitDirectory, nativeGitTimeoutInMs, log);
}

NativeGitProvider(@Nonnull File dotGitDirectory, long nativeGitTimeoutInMs, @Nonnull LogInterface log) {
NativeGitProvider(@NonNull File dotGitDirectory, long nativeGitTimeoutInMs, @NonNull LogInterface log) {
super(log);
this.dotGitDirectory = dotGitDirectory;
this.nativeGitTimeoutInMs = nativeGitTimeoutInMs;
Expand Down Expand Up @@ -251,7 +251,7 @@ public String getCommitId() throws GitCommitIdExecutionException {
* Returns the commit hash or null if no commits found.
*/
@Nullable
private String findLatestCommitForPath(@Nonnull String path) throws GitCommitIdExecutionException {
private String findLatestCommitForPath(@NonNull String path) throws GitCommitIdExecutionException {
try {
return runQuietGitCommand(
canonical, nativeGitTimeoutInMs,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pl/project13/core/PropertiesFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
package pl.project13.core;

import nu.studer.java.util.OrderedProperties;
import org.jspecify.annotations.NonNull;
import pl.project13.core.log.LogInterface;
import pl.project13.core.util.*;

import javax.annotation.Nonnull;
import java.io.*;
import java.nio.charset.Charset;
import java.util.Comparator;
Expand All @@ -44,7 +44,7 @@ public PropertiesFileGenerator(LogInterface log, BuildFileChangeListener buildFi
}

public void maybeGeneratePropertiesFile(
@Nonnull Properties localProperties,
@NonNull Properties localProperties,
File projectDir,
File propsFile,
Charset sourceCharset,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pl/project13/core/PropertiesFilterer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import java.util.List;
import java.util.Properties;

import org.jspecify.annotations.Nullable;
import pl.project13.core.log.LogInterface;

import javax.annotation.Nullable;

public class PropertiesFilterer {

Expand Down
Loading