added some debug/trace logging

This commit is contained in:
Brian Long 2020-12-10 15:21:58 -05:00
parent 388cdb2d15
commit e5f8a8f3a1

View File

@ -69,19 +69,28 @@ public class ExtendedGit extends CachedGit {
*/ */
public Ref normalize(String localBranchName, String exactRemoteBranchName) public Ref normalize(String localBranchName, String exactRemoteBranchName)
throws RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException, GitAPIException, IOException { throws RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException, GitAPIException, IOException {
if (this.logger.isTraceEnabled())
this.logger.trace("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "')");
Ref localRef = this.getRepository().exactRef(Constants.R_HEADS + localBranchName); Ref localRef = this.getRepository().exactRef(Constants.R_HEADS + localBranchName);
if (localRef == null) { if (localRef == null) {
if (this.logger.isDebugEnabled())
this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): local branch does not yet exist");
localRef = this.branchCreate() localRef = this.branchCreate()
.setUpstreamMode(SetupUpstreamMode.NOTRACK) .setUpstreamMode(SetupUpstreamMode.NOTRACK)
.setName(localBranchName) .setName(localBranchName)
.setStartPoint(exactRemoteBranchName) .setStartPoint(exactRemoteBranchName)
.call(); .call();
if (this.logger.isDebugEnabled())
this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): created local branch: " + localRef.getName());
} }
Ref checkoutRef = this.checkout() Ref checkoutRef = this.checkout()
.setName(localBranchName) .setName(localBranchName)
.setStartPoint(exactRemoteBranchName) .setStartPoint(exactRemoteBranchName)
.call(); .call();
if (this.logger.isDebugEnabled())
this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): checked out");
if (!localRef.getObjectId().getName().equals(checkoutRef.getObjectId().getName())) { if (!localRef.getObjectId().getName().equals(checkoutRef.getObjectId().getName())) {
this.logger.warn("A checkout did not move the local branch to the proper commit; performing reset: " + localRef.getName()); this.logger.warn("A checkout did not move the local branch to the proper commit; performing reset: " + localRef.getName());
@ -89,6 +98,8 @@ public class ExtendedGit extends CachedGit {
.setMode(ResetType.HARD) .setMode(ResetType.HARD)
.setRef(exactRemoteBranchName) .setRef(exactRemoteBranchName)
.call(); .call();
if (this.logger.isDebugEnabled())
this.logger.debug("normalize('" + localBranchName + "', '" + exactRemoteBranchName + "'): reset");
} }
return checkoutRef; return checkoutRef;