From 713b774a8527f6d8535a875d845db6916cbcccd9 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Sun, 11 Jul 2021 23:24:48 -0700
Subject: [PATCH] [ci skip] Use commit timestamp instead of build time in
 manifest (#6161)

---
 patches/server/Add-git-branch-and-commit-to-manifest.patch | 2 +-
 patches/server/Build-system-changes.patch                  | 2 +-
 patches/server/Setup-Gradle-project.patch                  | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/patches/server/Add-git-branch-and-commit-to-manifest.patch b/patches/server/Add-git-branch-and-commit-to-manifest.patch
index 85783bf1f2..82199dd787 100644
--- a/patches/server/Add-git-branch-and-commit-to-manifest.patch
+++ b/patches/server/Add-git-branch-and-commit-to-manifest.patch
@@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 --- a/build.gradle.kts
 +++ b/build.gradle.kts
 @@ -0,0 +0,0 @@ tasks.jar {
-         val git = Git(rootProject.layout.projectDirectory.path)
          val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
          val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
+         val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
 +        val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
          attributes(
              "Main-Class" to "org.bukkit.craftbukkit.Main",
diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch
index 13e2d5f5bf..999883bf7d 100644
--- a/patches/server/Build-system-changes.patch
+++ b/patches/server/Build-system-changes.patch
@@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
                  if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
 -                    Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
-+                    Date buildDate = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(Main.class.getPackage().getImplementationVendor()); // Paper
++                    Date buildDate = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse(Main.class.getPackage().getImplementationVendor()); // Paper
  
                      Calendar deadline = Calendar.getInstance();
                      deadline.add(Calendar.DAY_OF_YEAR, -7);
diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch
index 41642913a4..ae2be4b867 100644
--- a/patches/server/Setup-Gradle-project.patch
+++ b/patches/server/Setup-Gradle-project.patch
@@ -72,11 +72,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +        val git = Git(rootProject.layout.projectDirectory.path)
 +        val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
 +        val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
++        val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
 +        attributes(
 +            "Main-Class" to "org.bukkit.craftbukkit.Main",
 +            "Implementation-Title" to "CraftBukkit",
 +            "Implementation-Version" to "git-Paper-$implementationVersion",
-+            "Implementation-Vendor" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(Date()), // Paper
++            "Implementation-Vendor" to date, // Paper
 +            "Specification-Title" to "Bukkit",
 +            "Specification-Version" to project.version,
 +            "Specification-Vendor" to "Bukkit Team",