From e70e7f4f9d0f212a70dfbf7e73933403890db30a Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Fri, 1 Sep 2023 00:16:48 +0200
Subject: [PATCH] build: include tags in versioncode count

---
 .gitlab-ci.yml                                                  | 2 +-
 .../convention/src/main/kotlin/AndroidApplicationConvention.kt  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b251e96e0..e62c523e6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,7 +36,7 @@ version:
   stage: "test"
   script:
     - "export VERSION_NAME=$(git describe --abbrev=0 --tags HEAD)"
-    - "export VERSION_CODE=$(git rev-list --count $VERSION_NAME)"
+    - "export VERSION_CODE=$(git rev-list --count $VERSION_NAME --tags)"
     - "echo \"{\\\"name\\\":\\\"$VERSION_NAME\\\",\\\"code\\\":$VERSION_CODE}\" > version.json"
   artifacts:
     paths:
diff --git a/gradle/convention/src/main/kotlin/AndroidApplicationConvention.kt b/gradle/convention/src/main/kotlin/AndroidApplicationConvention.kt
index 034284bbc..19d57b839 100644
--- a/gradle/convention/src/main/kotlin/AndroidApplicationConvention.kt
+++ b/gradle/convention/src/main/kotlin/AndroidApplicationConvention.kt
@@ -27,7 +27,7 @@ class AndroidApplicationConvention : Plugin<Project> {
           val commit = git("rev-parse", "HEAD")
           val name = git("describe", "--always", "--tags", "HEAD")
 
-          versionCode = git("rev-list", "--count", "HEAD")?.toIntOrNull()
+          versionCode = git("rev-list", "--count", "HEAD", "--tags")?.toIntOrNull()
           versionName = git("describe", "--always", "--tags", "HEAD")
 
           val fancyVersionName = if (commit == null || name == null) name
-- 
GitLab