Skip to content

Commit

Permalink
Merge branch 'brachyura' of https://github.com/IrisShaders/Iris into …
Browse files Browse the repository at this point in the history
…brachyura
  • Loading branch information
coderbot16 committed Jan 30, 2022
2 parents 3389700 + ae42f69 commit a697aa8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions buildscript/src/main/java/Buildscript.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import net.fabricmc.mappingio.tree.MemoryMappingTree;
import net.fabricmc.tinyremapper.TinyRemapper;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;

Expand Down Expand Up @@ -189,18 +190,19 @@ public JavaJarDependency build() {

@Override
public Path getBuildJarPath() {
Repository repository = null;
String commitHash = "";
boolean isDirty = false;
try {
repository = Git.open(getProjectDir().toFile()).getRepository();
commitHash = repository.parseCommit(repository.resolve(Constants.HEAD).toObjectId()).getName().substring(0, 8);
repository.close();
} catch (IOException e) {
Git git = Git.open(getProjectDir().toFile());
isDirty = !git.status().call().getUncommittedChanges().isEmpty();
commitHash = git.getRepository().parseCommit(git.getRepository().resolve(Constants.HEAD).toObjectId()).getName().substring(0, 8);
git.close();
} catch (IOException | GitAPIException e) {
e.printStackTrace();
}


return getBuildLibsDir().resolve(getModId() + "-" + getVersion() + "-" + commitHash + ".jar");
return getBuildLibsDir().resolve(getModId() + "-" + getVersion() + "-" + commitHash + (isDirty ? "-dirty" : "") + ".jar");
}

@Override
Expand Down

0 comments on commit a697aa8

Please sign in to comment.