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

_JGIT_VERS = "4.7.8.201903121755-r"

_DOC_VERS = _JGIT_VERS  # Set to _JGIT_VERS unless using a snapshot

JGIT_DOC_URL = "http://download.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",
    )

def jgit_maven_repos():
    maven_jar(
        name = "jgit-lib",
        artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "d168acb5ec4a84589d9de9c6e0050d11ea7d070c",
        src_sha1 = "301ede02c84f679c9b3ad5bbbca4485f7c1f7cb3",
        unsign = True,
    )
    maven_jar(
        name = "jgit-servlet",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "d6390f85adeb78f238826820a42479e9c82410ed",
        unsign = True,
    )
    maven_jar(
        name = "jgit-archive",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "713a58d64738d6b289983436f1f6d29904639c14",
    )
    maven_jar(
        name = "jgit-junit",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "cea8dced85441fd3bad429a2417cffad145e87b5",
        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

@@ -80,22 +80,22 @@
 4.7.
-8
+9
 .20190
-3121755
+4161809
 -r%22%0A
@@ -1065,111 +1065,111 @@
  = %22
-d168acb5ec4a84589d9de9c6e0050d11ea7d070c%22,%0A        src_sha1 = %22301ede02c84f679c9b3ad5bbbca4485f7c1f7cb3
+14fb9628876e69d1921776c84c7343ddabe7db31%22,%0A        src_sha1 = %226717cab511548f01f07db2442d104ba901402d49
 %22,%0A 
@@ -1377,48 +1377,48 @@
  = %22
-d6390f85adeb78f238826820a42479e9c82410ed
+4b9006c68e257e4397a34a6022c6729c657129d8
 %22,%0A 
@@ -1622,48 +1622,48 @@
  = %22
-713a58d64738d6b289983436f1f6d29904639c14
+41fb617b0d51afb2f6c1345e8ef57f3caece790a
 %22,%0A 
@@ -1840,48 +1840,48 @@
  = %22
-cea8dced85441fd3bad429a2417cffad145e87b5
+10ad697deb13a90b957e462589fb92a5cf371909
 %22,%0A 

Upgrade JGit to 4.7.9.201904161809-r