Fix IndexOutOfBoundsException in GitUtil.getRepositoryURL when no remotes configured#326
Conversation
…otes exist Agent-Logs-Url: https://github.com/getappmap/appmap-java/sessions/2575e3fc-ec41-4655-ab8e-0d6c7f3670b7 Co-authored-by: kgilpin <86395+kgilpin@users.noreply.github.com>
…itory 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>
Done in 5956839. |
8a69319 to
871a9c9
Compare
dividedmind
left a comment
There was a problem hiding this comment.
I've added tests and changed the agent to look for the git repo based on the appmap.yml instead of the working directory (which is IMO less surprising and allowed me to add unit tests without ungodly complications — it seems JVM doesn't have a concept of the working directory or how to change it).
@kgilpin please take a look; if it looks good, you can go ahead and squash merge (there's a bunch of wip commits here); please make sure to use proper fix: ... commit message subject for semantic-release. Or just let me know and I'll do it :)
kgilpin
left a comment
There was a problem hiding this comment.
Looks good - I have been using this in my benchmark
|
🎉 This PR is included in version 1.30.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Recording fails with
IndexOutOfBoundsExceptioninGitUtil.getRepositoryURLwhen the git repository has no remotes — the fallback path ofremotes.get(0)is hit unconditionally on a potentially empty list.Changes
nullearly ifremotes.isEmpty()instead of falling through toremotes.get(0)nullif the selected remote has no URIs configuredorElseGetoverorElse— avoids eagerly evaluatingremotes.get(0)when "origin" is presentgetRepositoryURL()returnsnullinstead of""when no URL is available, allowing callers to distinguish "no remote" from an actual empty stringAppMapSerializer.writeMetadata()only writes therepositorykey whengetRepositoryURL()returns a non-null value