Skip to content

Commit ece71c2

Browse files
committed
Build: GitInfo function to build a raw github content URL
1 parent dcd3ed4 commit ece71c2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

build-logic/src/main/kotlin/GitInfo.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import org.gradle.kotlin.dsl.extra
2424
* Container to memoize Git information retrieved via `git` command executions across all Gradle
2525
* projects.
2626
*/
27-
class GitInfo(val gitHead: String, val gitDescribe: String) {
27+
class GitInfo(val gitHead: String, val gitDescribe: String, private val rawLinkRef: String) {
28+
29+
fun rawGithubLink(file: String): String =
30+
"https://raw.githubusercontent.com/apache/polaris/$rawLinkRef/$file"
31+
2832
companion object {
2933
private fun execGit(rootProject: Project, vararg args: Any): String {
3034
val out =
@@ -56,7 +60,8 @@ class GitInfo(val gitHead: String, val gitDescribe: String) {
5660
execGit(rootProject, "describe", "--always", "--dirty")
5761
}
5862
else ""
59-
val gitInfo = GitInfo(gitHead, gitDescribe)
63+
val rawLinkRef = if (isRelease) gitDescribe else "HEAD"
64+
val gitInfo = GitInfo(gitHead, gitDescribe, rawLinkRef)
6065
rootProject.extra["gitInfo"] = gitInfo
6166
return gitInfo
6267
}

0 commit comments

Comments
 (0)