Unverified Commit 7731b3f1 authored by Burak's avatar Burak Committed by GitHub
Browse files

Override codegen version commit hash in PR diffs (#1636)

* Override codegen version commit hash in PR diffs

* Move version commit hash override to shell script
parent e4e9a1d3
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -40,8 +40,16 @@ tasks.compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

fun gitCommitHash() =
    try {
fun gitCommitHash(): String {
    // Use commit hash from env if provided, it is helpful to override commit hash in some contexts.
    // For example: while generating diff for generated SDKs we don't want to see version diff,
    // so we are overriding commit hash to something fixed
    val commitHashFromEnv = System.getenv("SMITHY_RS_VERSION_COMMIT_HASH_OVERRIDE")
    if (commitHashFromEnv != null) {
        return commitHashFromEnv
    }

    return try {
        val output = ByteArrayOutputStream()
        exec {
            commandLine = listOf("git", "rev-parse", "HEAD")
@@ -51,6 +59,7 @@ fun gitCommitHash() =
    } catch (ex: Exception) {
        "unknown"
    }
}

val generateSmithyRuntimeCrateVersion by tasks.registering {
    // generate the version of the runtime to use as a resource.
+2 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ if [[ $# -ne 1 ]]; then
    exit 1
fi

# Override version commit hash to prevent unnecessary diffs
export SMITHY_RS_VERSION_COMMIT_HASH_OVERRIDE=ci
base_revision="$1"
./tools/codegen-diff-revisions.py . "${base_revision}"