Skip to content

Commit 75c8fc9

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix/labels-bypass-trivial-filter
2 parents f06c820 + cead37a commit 75c8fc9

7 files changed

Lines changed: 102 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [1.30.1](https://github.com/getappmap/appmap-java/compare/v1.30.0...v1.30.1) (2026-05-11)
2+
3+
4+
### Bug Fixes
5+
6+
* Don't crash when running in git repositories without remotes ([48723a8](https://github.com/getappmap/appmap-java/commit/48723a8695cebf66a5e1d1704ed7fa7ba8341b25))
7+
18
# [1.30.0](https://github.com/getappmap/appmap-java/compare/v1.29.0...v1.30.0) (2026-01-26)
29

310

‎agent/src/main/java/com/appland/appmap/config/AppMapConfig.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.tinylog.TaggedLogger;
2828
import org.tinylog.configuration.Configuration;
2929

30-
import com.alibaba.fastjson.JSON;
3130
import com.appland.appmap.Agent;
3231
import com.appland.appmap.cli.CLI;
3332
import com.appland.appmap.util.FullyQualifiedName;
@@ -115,7 +114,7 @@ private static Path findConfig(Path configFile, boolean mustExist) throws FileNo
115114
*
116115
* @return The AppMapConfig singleton
117116
*/
118-
static AppMapConfig load(Path configFile, boolean mustExist) {
117+
public static AppMapConfig load(Path configFile, boolean mustExist) {
119118
InputStream inputStream = null;
120119

121120
try {

‎agent/src/main/java/com/appland/appmap/util/GitUtil.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.util.Map;
1414
import java.util.Optional;
1515

16+
import javax.annotation.Nullable;
17+
1618
import org.eclipse.jgit.api.Git;
1719
import org.eclipse.jgit.api.errors.GitAPIException;
1820
import org.eclipse.jgit.errors.RevisionSyntaxException;
@@ -60,7 +62,8 @@ public static GitUtil open() throws IOException {
6062
FileRepositoryBuilder builder = new FileRepositoryBuilder()
6163
.readEnvironment();
6264

63-
builder.findGitDir();
65+
Path fsBase = AppMapConfig.get().configFile.toAbsolutePath().getParent();
66+
builder.findGitDir(fsBase.toFile());
6467
if (builder.getGitDir() == null) {
6568
logger.debug("Working directory {}, not in a git repo", () -> Paths.get("").toAbsolutePath());
6669
return null;
@@ -73,7 +76,6 @@ public static GitUtil open() throws IOException {
7376
return null;
7477
}
7578

76-
Path fsBase = AppMapConfig.get().configFile.toAbsolutePath().getParent();
7779
ObjectId tree = repository.resolve(Constants.HEAD + "^{tree}");
7880
if (tree == null) {
7981
logger.warn("Couldn't resolve HEAD to a tree in {}, source paths may be incorrect", fsBase);
@@ -96,7 +98,7 @@ public Repository getRepository() {
9698
return git.getRepository();
9799
}
98100

99-
public String getRepositoryURL() {
101+
public @Nullable String getRepositoryURL() {
100102
try {
101103
List<RemoteConfig> remotes = git.remoteList().call();
102104
if (remotes.isEmpty()) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.appland.appmap.record;
2+
3+
import static org.junit.jupiter.api.Assertions.assertFalse;
4+
import static org.mockito.Mockito.mock;
5+
import static org.mockito.Mockito.when;
6+
7+
import java.io.StringWriter;
8+
import java.nio.file.Files;
9+
import java.nio.file.Path;
10+
import java.util.Map;
11+
12+
import org.eclipse.jgit.api.Git;
13+
import org.junit.jupiter.api.BeforeEach;
14+
import org.junit.jupiter.api.Test;
15+
import org.junit.jupiter.api.io.TempDir;
16+
17+
import com.appland.appmap.config.AppMapConfig;
18+
import com.appland.appmap.record.Recorder.Metadata;
19+
20+
public class AppMapSerializerTest {
21+
@TempDir
22+
Path tempDir;
23+
24+
@BeforeEach
25+
public void setup() throws Exception {
26+
Path configFile = tempDir.resolve("appmap.yml");
27+
Files.write(configFile, "name: test\npackages: []".getBytes());
28+
AppMapConfig.load(configFile, true);
29+
}
30+
31+
@Test
32+
public void testMetadataNoRepositoryURL() throws Exception {
33+
try (var gitRepo = Git.init().setDirectory(tempDir.toFile()).call()) {
34+
Path testFile = tempDir.resolve("test.txt");
35+
Files.write(testFile, "test".getBytes());
36+
gitRepo.add().addFilepattern("test.txt").call();
37+
gitRepo.commit().setMessage("initial commit").call();
38+
}
39+
40+
Metadata metadata = new Metadata("test-recorder", "test-type");
41+
42+
StringWriter writer = new StringWriter();
43+
try (AppMapSerializer serializer = AppMapSerializer.open(writer)) {
44+
serializer.write(new CodeObjectTree(), metadata, Map.of());
45+
}
46+
47+
String json = writer.toString();
48+
assertFalse(json.contains("\"repository\""), "Metadata should not contain 'repository' if URL is null. JSON: " + json);
49+
}
50+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.appland.appmap.util;
2+
3+
import static org.junit.jupiter.api.Assertions.assertNull;
4+
5+
import java.nio.file.Files;
6+
import java.nio.file.Path;
7+
8+
import org.eclipse.jgit.api.Git;
9+
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.io.TempDir;
11+
12+
import com.appland.appmap.config.AppMapConfig;
13+
14+
public class GitUtilTest {
15+
@TempDir
16+
Path tempDir;
17+
18+
@Test
19+
public void testGetRepositoryURLNoRemotes() throws Exception {
20+
try (Git git = Git.init().setDirectory(tempDir.toFile()).call()) {
21+
Path testFile = tempDir.resolve("test.txt");
22+
Files.write(testFile, "test".getBytes());
23+
git.add().addFilepattern("test.txt").call();
24+
git.commit().setMessage("initial commit").call();
25+
26+
Path configFile = tempDir.resolve("appmap.yml");
27+
Files.write(configFile, "name: test\npackages: []".getBytes());
28+
29+
AppMapConfig.load(configFile, true);
30+
31+
try (GitUtil gitUtil = GitUtil.open()) {
32+
assertNull(gitUtil.getRepositoryURL(), "Repository URL should be null when no remotes exist");
33+
}
34+
}
35+
}
36+
}

‎agent/test/helper.bash‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,12 @@ start_petclinic() {
245245
AGENT_JAR="$(find_agent_jar)"
246246

247247
local cfg="$WD/test/petclinic/appmap.yml"
248+
cp "$cfg" "${fixture_dir}/appmap.yml"
248249
local out="${fixture_dir}/tmp/appmap"
249250
pushd build/fixtures/spring-petclinic >/dev/null
250251
./mvnw ${MAVEN_PROFILE} ${BATS_VERSION+--quiet} -DskipTests -Dcheckstyle.skip=true -Dspring-javaformat.skip=true \
251252
-Dspring-boot.run.agents=$AGENT_JAR \
252-
-Dspring-boot.run.jvmArguments="-Dappmap.config.file='${cfg}' -Dappmap.output.directory='${out}' $jvmargs" \
253+
-Dspring-boot.run.jvmArguments="-Dappmap.config.file='${fixture_dir}/appmap.yml' -Dappmap.output.directory='${out}' $jvmargs" \
253254
spring-boot:run \
254255
&>$LOG 3>&- &
255256
export JVM_MAIN_CLASS=PetClinicApplication

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212

1313
ext {
14-
defaultVersion = '1.30.0'
14+
defaultVersion = '1.30.1'
1515
}
1616

1717
def defaultGroupId = 'com.appland'

0 commit comments

Comments
 (0)