load("//tools/bzl:maven_jar.bzl", "MAVEN_CENTRAL", "maven_jar")

_JGIT_VERS = "5.1.15.202012011955-r"

_DOC_VERS = _JGIT_VERS  # Set to _JGIT_VERS unless using a snapshot

JGIT_DOC_URL = "https://archive.eclipse.org/jgit/site/" + _DOC_VERS + "/apidocs"

_JGIT_REPO = MAVEN_CENTRAL  # Leave here even if set to MAVEN_CENTRAL.

# set this to use a local version.
# "/home/<user>/projects/jgit"
LOCAL_JGIT_REPO = ""

def jgit_repos():
    if LOCAL_JGIT_REPO:
        native.local_repository(
            name = "jgit",
            path = LOCAL_JGIT_REPO,
        )
        jgit_maven_repos_dev()
    else:
        jgit_maven_repos()

def jgit_maven_repos_dev():
    # Transitive dependencies from JGit's WORKSPACE.
    maven_jar(
        name = "hamcrest-library",
        artifact = "org.hamcrest:hamcrest-library:1.3",
        sha1 = "4785a3c21320980282f9f33d0d1264a69040538f",
    )
    maven_jar(
        name = "jzlib",
        artifact = "com.jcraft:jzlib:1.1.1",
        sha1 = "a1551373315ffc2f96130a0e5704f74e151777ba",
    )

def jgit_maven_repos():
    maven_jar(
        name = "jgit-lib",
        artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "ca4a5fbd38cfad3ad386b46464b0e753eca3baea",
        src_sha1 = "39a4180b70ac3024d68ee9781198e88abf567ccf",
        unsign = True,
    )
    maven_jar(
        name = "jgit-servlet",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "698fa84e35787eab380efadc2df52706dbac5268",
        unsign = True,
    )
    maven_jar(
        name = "jgit-archive",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "27c731c41c8cb45e6bccdaac14311bda1d724437",
    )
    maven_jar(
        name = "jgit-junit",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "6f961edbfecf5928c87d46b08acf2e1625a53089",
        unsign = True,
    )

def jgit_dep(name):
    mapping = {
        "@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive",
        "@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit",
        "@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit",
        "@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar",
        "@jgit-servlet//jar": "@jgit//org.eclipse.jgit.http.server:jgit-servlet",
    }

    if LOCAL_JGIT_REPO:
        return mapping[name]
    else:
        return name

@@ -81,22 +81,22 @@
 .1.1
-5
+6
 .202
-012011955
+106041830
 -r%22%0A
@@ -1215,111 +1215,111 @@
  = %22
-ca4a5fbd38cfad3ad386b46464b0e753eca3baea%22,%0A        src_sha1 = %2239a4180b70ac3024d68ee9781198e88abf567ccf
+1b32273b9b8326a14355374702799b6cd4a94050%22,%0A        src_sha1 = %2262a010fe8e0de9c4684348f3853da3c817257165
 %22,%0A 
@@ -1527,48 +1527,48 @@
  = %22
-698fa84e35787eab380efadc2df52706dbac5268
+f375f3c6cfe37096ee984d3a2f380817446ac5f0
 %22,%0A 
@@ -1773,47 +1773,47 @@
 = %222
-7c731c41c8cb45e6bccdaac14311bda1d724437
+0378bb3138a9ab8d2e13036a2f3e4719caad7a2
 %22,%0A 
@@ -1990,48 +1990,48 @@
  = %22
-6f961edbfecf5928c87d46b08acf2e1625a53089
+9563231cf411841a78f9bb703782b0f0a716d420
 %22,%0A 

Update jgit to 5.1.16.202106041830-r