mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-08 12:03:29 -04:00
34 lines
1009 B
Groovy
34 lines
1009 B
Groovy
import java.io.IOException
|
|
plugins{
|
|
id 'com.android.application' version '8.7.2' apply false
|
|
id 'com.android.library' version '8.7.2' apply false
|
|
}
|
|
|
|
String getGitHash(String project) {
|
|
def command = Runtime.getRuntime().exec("git rev-list -1 HEAD " + project + "/src")
|
|
def returnCode = command.waitFor()
|
|
if (returnCode != 0) {
|
|
throw new IOException("Command 'getGitHash()' exited with " + returnCode)
|
|
}
|
|
String gitCommitHash = command.inputStream.text.trim()
|
|
return gitCommitHash
|
|
}
|
|
|
|
Boolean gitUsed() {
|
|
def returnCode = Runtime.getRuntime().exec("git rev-parse --is-inside-work-tree").waitFor()
|
|
switch(returnCode){
|
|
case 127:
|
|
println("git not found");
|
|
return false;
|
|
break;
|
|
case 128:
|
|
println("not inside a git repository");
|
|
return false;
|
|
break;
|
|
case 0:
|
|
return true;
|
|
default:
|
|
throw new IOException("Command 'gitUsed()' exited with " + returnCode)
|
|
}
|
|
}
|