Skip to content

Commit

Permalink
added check so that tests dont break
Browse files Browse the repository at this point in the history
  • Loading branch information
salimbouch committed Dec 12, 2024
1 parent d112979 commit ff61a2b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,14 @@ public Path getSettingsPath() {

@Override
public Path getSettingsGitRepository() {

Path settingsPath = getSettingsPath();

if (Objects.isNull(settingsPath)) {
error("No settings repository was found.");
}

// check whether the settings path has a .git folder only if its not a symbolic link
if (!Files.exists(settingsPath.resolve(".git")) && !Files.isSymbolicLink(settingsPath)) {
error("Settings repository exists but is not a git repository.");
return null;
Expand Down Expand Up @@ -1160,10 +1162,12 @@ public void saveCurrentCommitId(Path repository, Path trackedCommitIdPath) {
return;
}
String currentCommitId = getGitContext().runGitCommandAndGetSingleOutput("Failed to get current commit id.", repository, "rev-parse", "HEAD");
try {
Files.writeString(trackedCommitIdPath, currentCommitId);
} catch (IOException e) {
throw new IllegalStateException("Failed to save commit ID", e);
if (currentCommitId != null) {
try {
Files.writeString(trackedCommitIdPath, currentCommitId);
} catch (IOException e) {
throw new IllegalStateException("Failed to save commit ID", e);
}
}
}
}

0 comments on commit ff61a2b

Please sign in to comment.