Skip to content

Commit 5956839

Browse files
Copilotkgilpin
andauthored
Return null from getRepositoryURL when no remotes; skip writing repository key in serializer
Agent-Logs-Url: https://github.com/getappmap/appmap-java/sessions/9269e403-28ed-4394-be5f-17ca657e822a Co-authored-by: kgilpin <86395+kgilpin@users.noreply.github.com>
1 parent 5a406a9 commit 5956839

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎agent/src/main/java/com/appland/appmap/record/AppMapSerializer.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ private void writeMetadata(GitUtil git, Metadata metadata) throws IOException {
185185
this.json.writeKey("git");
186186
this.json.startObject();
187187
{
188-
this.json.writeKey("repository");
189-
this.json.writeValue(git.getRepositoryURL());
188+
String repositoryURL = git.getRepositoryURL();
189+
if (repositoryURL != null) {
190+
this.json.writeKey("repository");
191+
this.json.writeValue(repositoryURL);
192+
}
190193
this.json.writeKey("branch");
191194
this.json.writeValue(git.getBranch());
192195
this.json.writeKey("commit");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@ public String getRepositoryURL() {
100100
try {
101101
List<RemoteConfig> remotes = git.remoteList().call();
102102
if (remotes.isEmpty()) {
103-
return "";
103+
return null;
104104
}
105105
Optional<RemoteConfig> originConfig = remotes.stream().filter(r -> r.getName().equals("origin")).findFirst();
106106
RemoteConfig remote = originConfig.orElseGet(() -> remotes.get(0));
107107
List<URIish> uris = remote.getURIs();
108108
if (uris.isEmpty()) {
109-
return "";
109+
return null;
110110
}
111111
return uris.get(0).toASCIIString();
112112
} catch (GitAPIException e) {
113113
logger.warn(e);
114114
}
115-
return "";
115+
return null;
116116
}
117117

118118
public String getBranch() {

0 commit comments

Comments
 (0)