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

_JGIT_VERS = "4.7.0.201704051617-r.15-gc4e952109"

_DOC_VERS = "4.7.0.201704051617-r" # Set to _JGIT_VERS unless using a snapshot

JGIT_DOC_URL = "http://download.eclipse.org/jgit/site/" + _DOC_VERS + "/apidocs"

_JGIT_REPO = GERRIT # 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,
    )
  else:
    jgit_maven_repos()

def jgit_maven_repos():
    maven_jar(
        name = "jgit_lib",
        artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "875277521153030e2bdab12bf602b740232b2b28",
        src_sha1 = "f9adcd3ef0f77c5db16569771f95bc0142c36f46",
        unsign = True,
    )
    maven_jar(
        name = "jgit_servlet",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "e1037f50696a6e19fb5d30f9d44cb31e3c5fe8b0",
        unsign = True,
    )
    maven_jar(
        name = "jgit_archive",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "660bc82c9ff3c33249d269860d9793e830d6c374",
    )
    maven_jar(
        name = "jgit_junit",
        artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS,
        repository = _JGIT_REPO,
        sha1 = "c2b28646cc2531df947a9e0f73fa9c415567b05e",
        unsign = True,
    )

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

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

@@ -122,21 +122,21 @@
 7-r.
-15-gc4e952109
+37-gc80d8c590
 %22%0A%0A_
@@ -799,111 +799,111 @@
  = %22
-875277521153030e2bdab12bf602b740232b2b28%22,%0A        src_sha1 = %22f9adcd3ef0f77c5db16569771f95bc0142c36f46
+edb739cd1e7c72dab361a8f6011807ae7fae35e2%22,%0A        src_sha1 = %22ddf922143dd88ec8fbd2c44f48f203340e6b4d54
 %22,%0A 
@@ -1112,47 +1112,47 @@
 = %22e
-1037f50696a6e19fb5d30f9d44cb31e3c5fe8b0
+864cb9f7e16d77ff75805708cd82e6f82a73246
 %22,%0A 
@@ -1356,48 +1356,48 @@
  = %22
-660bc82c9ff3c33249d269860d9793e830d6c374
+cc944356eb8ca74446341729d539f5b9faccb698
 %22,%0A 
@@ -1574,48 +1574,48 @@
  = %22
-c2b28646cc2531df947a9e0f73fa9c415567b05e
+eae23cc952d8b9d332287f7a4d4200c17ae78411
 %22,%0A 

Update JGit to 4.7.0.201704051617-r.37-gc80d8c590