Skip to content

Commit

Permalink
patch: Log status when repo is unclean
Browse files Browse the repository at this point in the history
Fixes #91
  • Loading branch information
ajoberstar committed Apr 22, 2023
1 parent bca420f commit b8c4613
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -19,9 +13,6 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
Expand All @@ -32,7 +23,7 @@

/**
* Supplies an inventory of a Git repository.
*
* <p>
* This is intentionally package private.
*/
final class GitInventorySupplier implements VcsInventorySupplier {
Expand Down Expand Up @@ -105,7 +96,17 @@ public VcsInventory getInventory() {

private boolean isClean() {
try {
return new Git(repo).status().call().isClean();
var status = new Git(repo).status().call();
if (!status.isClean()) {
logger.info("Git repository is not clean: added={}, changed={}, removed={}, untracked={}, modified={}, missing={}",
status.getAdded(),
status.getChanged(),
status.getRemoved(),
status.getUntracked(),
status.getModified(),
status.getMissing());
}
return status.isClean();
} catch (GitAPIException e) {
logger.error("Failed to determine status of repository. Assuming not clean.", e);
// TODO should this throw up?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -60,7 +57,7 @@ public Version reckon() {
var reckoned = reckonTargetVersion(inventory, targetNormal);

if (reckoned.isSignificant() && !inventory.isClean()) {
throw new IllegalStateException("Cannot release a final or significant stage without a clean repo.");
throw new IllegalStateException("Cannot release a final or significant stage without a clean repo. Review INFO logs for more details.");
}

if (inventory.getClaimedVersions().contains(reckoned) && !inventory.getCurrentVersion().map(reckoned::equals).orElse(false)) {
Expand Down

0 comments on commit b8c4613

Please sign in to comment.