Skip to content

Commit

Permalink
Support for Git commit hashes when building BlazeVersionData
Browse files Browse the repository at this point in the history
  • Loading branch information
odisseus committed Dec 9, 2024
1 parent 0fb3f81 commit e272569
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.google.idea.blaze.qsync.project.ProjectTarget;
import com.google.idea.blaze.qsync.project.QuerySyncLanguage;
import com.intellij.openapi.diagnostic.Logger;
import java.math.BigInteger;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Optional;
Expand Down Expand Up @@ -155,7 +156,15 @@ public BlazeVersionData getBlazeVersionData() {
try {
data.setClientCl(Long.parseLong(revision));
} catch (NumberFormatException e) {
logger.warn(e);
// Most likely this is a Git commit hash (40 hex digits)
logger.warn(String.format("setClientCl(%s)", revision.substring(0, 16)));
try {
var prefix = revision.substring(0, 16);
data.setClientCl(new BigInteger(prefix, 16).longValue());
} catch (NumberFormatException ignored) {
// If the fallback also fails, report the original exception
logger.warn(e);
}
}
});
blazeProject
Expand Down

0 comments on commit e272569

Please sign in to comment.