├── VERSION_TEMPLATE ├── .gitattributes ├── deps.edn ├── .gitignore ├── .github ├── workflows │ ├── test.yml │ ├── snapshot.yml │ ├── doc-build.yml │ └── release.yml └── PULL_REQUEST_TEMPLATE ├── script └── build │ ├── update_version │ ├── git_revision │ ├── branch_revision │ ├── trunk_revision │ └── revision ├── CONTRIBUTING.md ├── src ├── test │ └── clojure │ │ └── clojure │ │ └── tools │ │ ├── gitlibs │ │ └── test_impl.clj │ │ └── test_gitlibs.clj └── main │ └── clojure │ └── clojure │ └── tools │ ├── gitlibs │ ├── config.clj │ └── impl.clj │ └── gitlibs.clj ├── pom.xml ├── CHANGELOG.md ├── README.md ├── LICENSE └── epl.html /VERSION_TEMPLATE: -------------------------------------------------------------------------------- 1 | 2.6.GENERATED_VERSION 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | epl.html linguist-vendored=true 2 | -------------------------------------------------------------------------------- /deps.edn: -------------------------------------------------------------------------------- 1 | {:paths ["src/main/clojure"] 2 | :deps {org.clojure/clojure {:mvn/version "1.11.4"}}} 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | target/ 4 | .nrepl* 5 | .cpcache 6 | .lein* 7 | .calva/ 8 | .clj-kondo/ 9 | .lsp/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | call-test: 7 | uses: clojure/build.ci/.github/workflows/test.yml@master 8 | -------------------------------------------------------------------------------- /script/build/update_version: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | mvn versions:set -DgenerateBackupPoms=false -DnewVersion=`script/build/revision`-SNAPSHOT 6 | -------------------------------------------------------------------------------- /.github/workflows/snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Snapshot on demand 2 | 3 | on: [workflow_dispatch] 4 | 5 | jobs: 6 | call-snapshot: 7 | uses: clojure/build.ci/.github/workflows/snapshot.yml@master 8 | secrets: inherit 9 | -------------------------------------------------------------------------------- /.github/workflows/doc-build.yml: -------------------------------------------------------------------------------- 1 | name: Build API Docs 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | call-doc-build-workflow: 8 | uses: clojure/build.ci/.github/workflows/doc-build.yml@master 9 | with: 10 | project: clojure/tools.gitlibs 11 | -------------------------------------------------------------------------------- /script/build/git_revision: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Return the portion of the version number generated from git 4 | # 5 | 6 | set -e 7 | 8 | trunk_basis=`script/build/trunk_revision` 9 | sha=`git rev-parse HEAD` 10 | 11 | sha=${sha:0:${#sha}-34} # drop the last 34 characters, keep 6 12 | 13 | echo $trunk_basis 14 | -------------------------------------------------------------------------------- /script/build/branch_revision: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # If on a branch other than master, returns the number of commits made off of master 4 | # If on master, returns 0 5 | 6 | set -e 7 | 8 | master_tag=`git rev-parse --abbrev-ref HEAD` 9 | 10 | if [ "$master_tag" == "master" ]; then 11 | echo "0" 12 | else 13 | last_commit=`git rev-parse HEAD` 14 | revision=`git rev-list master..$last_commit | wc -l` 15 | echo $revision 16 | fi 17 | -------------------------------------------------------------------------------- /script/build/trunk_revision: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Returns the number of commits made since the v0.0 tag 4 | 5 | set -e 6 | 7 | REVISION=`git --no-replace-objects describe --match v0.0` 8 | 9 | # Extract the version number from the string. Do this in two steps so 10 | # it is a little easier to understand. 11 | REVISION=${REVISION:5} # drop the first 5 characters 12 | REVISION=${REVISION:0:${#REVISION}-9} # drop the last 9 characters 13 | 14 | echo $REVISION 15 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE: -------------------------------------------------------------------------------- 1 | Hi! Thanks for your interest in contributing to this project. 2 | 3 | Clojure contrib projects do not use GitHub issues or pull requests. 4 | If you would like to discuss a problem or enhancement request, please 5 | file a question to discuss on https://ask.clojure.org and use the 6 | appropriate category under "Contrib libs". If necessary, a JIRA will 7 | be filed by a developer. 8 | 9 | For more information on contributing to Clojure projects, see: 10 | https://clojure.org/dev 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | This is a [Clojure contrib] project. 2 | 3 | Under the Clojure contrib [guidelines], this project cannot accept 4 | pull requests. All patches must be submitted via [JIRA]. 5 | 6 | See [Contributing] on the Clojure website for 7 | more information on how to contribute. 8 | 9 | [Clojure contrib]: https://clojure.org/community/contrib_libs 10 | [Contributing]: https://clojure.org/community/contributing 11 | [JIRA]: http://dev.clojure.org/jira/browse/TDEPS 12 | [guidelines]: https://clojure.org/community/contrib_howto 13 | -------------------------------------------------------------------------------- /script/build/revision: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Return the complete revision number 4 | # ...-[-qualifier] 5 | 6 | set -e 7 | 8 | version_template=`cat VERSION_TEMPLATE` 9 | 10 | if [[ "$version_template" =~ ^[0-9]+\.[0-9]+\.GENERATED_VERSION(-[a-zA-Z0-9]+)?$ ]]; then 11 | 12 | git_revision=`script/build/git_revision` 13 | echo ${version_template/GENERATED_VERSION/$git_revision} 14 | 15 | else 16 | echo "Invalid version template string: $version_template" >&2 17 | exit -1 18 | fi 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release on demand 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | releaseVersion: 7 | description: "Version to release" 8 | required: true 9 | snapshotVersion: 10 | description: "Snapshot version after release" 11 | required: true 12 | 13 | jobs: 14 | call-release: 15 | uses: clojure/build.ci/.github/workflows/release.yml@master 16 | with: 17 | releaseVersion: ${{ github.event.inputs.releaseVersion }} 18 | snapshotVersion: ${{ github.event.inputs.snapshotVersion }} 19 | secrets: inherit -------------------------------------------------------------------------------- /src/test/clojure/clojure/tools/gitlibs/test_impl.clj: -------------------------------------------------------------------------------- 1 | (ns clojure.tools.gitlibs.test-impl 2 | (:require 3 | [clojure.test :refer :all] 4 | [clojure.tools.gitlibs.impl :as impl])) 5 | 6 | (deftest test-clean-url 7 | (are [url expected-path] 8 | (= expected-path (#'impl/clean-url url)) 9 | 10 | ;; url formats - don't use user or port 11 | "ssh://git@gitlab.com:3333/org/repo.git" "ssh/gitlab.com/org/repo" 12 | "ssh://git@gitlab.org.net/org/repo.git" "ssh/gitlab.org.net/org/repo" 13 | "ssh://user@host.xz/~user/repo.git/" "ssh/host.xz/_TILDE_user/repo" 14 | "https://github.com/org/repo.git" "https/github.com/org/repo" 15 | "git://host.xz/path/to/repo.git/" "git/host.xz/path/to/repo" 16 | 17 | ;; scp style url (most common github ssh url format) 18 | "git@github.com:org/repo.git" "ssh/github.com/org/repo" 19 | "git@github.com:dotted.org/dotted.repo.git" "ssh/github.com/dotted.org/dotted.repo" 20 | "host.xz:~user/path/to/repo.git/" "ssh/host.xz/_TILDE_user/path/to/repo" 21 | 22 | ;; file scheme 23 | "file:///Users/me/code/repo.git" "file/Users/me/code/repo" 24 | "file://../foo.git" "file/REL/_DOTDOT_/foo" 25 | "file://~/path/repo.git" "file/REL/_TILDE_/path/repo" 26 | 27 | ;; file repos - handle relative vs absolute, handle . .. ~ 28 | "/Users/me/code/repo.git" "file/Users/me/code/repo" 29 | "../foo.git" "file/REL/_DOTDOT_/foo" 30 | "./foo.git" "file/REL/_DOT_/foo" 31 | "~user/foo.git" "file/REL/_TILDE_user/foo" 32 | 33 | ;; git - unknown transport with url rewrite in gitconfig (unusual, but do something useful) 34 | "work:repo.git" "ssh/work/repo")) 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/clojure/clojure/tools/gitlibs/config.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.tools.gitlibs.config 10 | "Implementation, use at your own risk" 11 | (:require 12 | [clojure.java.io :as jio] 13 | [clojure.string :as str])) 14 | 15 | (set! *warn-on-reflection* true) 16 | 17 | (defn- read-config-value 18 | "Read a config value from each of these in order, taking the first value found: 19 | * Java system property 20 | * env variable 21 | * default value" 22 | [property env default] 23 | (or 24 | (System/getProperty property) 25 | (System/getenv env) 26 | default)) 27 | 28 | (defn- init-config 29 | [] 30 | {:gitlibs/dir 31 | (.getCanonicalPath 32 | (let [lib-dir (or (System/getProperty "clojure.gitlibs.dir") (System/getenv "GITLIBS"))] 33 | (if (str/blank? lib-dir) 34 | (jio/file (System/getProperty "user.home") ".gitlibs") 35 | (jio/file lib-dir)))) 36 | 37 | :gitlibs/command 38 | (or (System/getProperty "clojure.gitlibs.command") (System/getenv "GITLIBS_COMMAND") "git") 39 | 40 | :gitlibs/debug 41 | (Boolean/parseBoolean (or (System/getProperty "clojure.gitlibs.debug") (System/getenv "GITLIBS_DEBUG") "false")) 42 | 43 | :gitlibs/terminal 44 | (Boolean/parseBoolean (or (System/getProperty "clojure.gitlibs.terminal") (System/getenv "GITLIBS_TERMINAL") "false"))}) 45 | 46 | (def CONFIG 47 | "Config map - deref to access" 48 | (delay (init-config))) -------------------------------------------------------------------------------- /src/test/clojure/clojure/tools/test_gitlibs.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.tools.test-gitlibs 10 | (:require 11 | [clojure.java.io :as jio] 12 | [clojure.test :refer :all] 13 | [clojure.tools.gitlibs :as gl])) 14 | 15 | (def repo-url "https://github.com/clojure/spec.alpha.git") 16 | 17 | (deftest test-resolve 18 | (is (= (gl/resolve repo-url "739c1af5") 19 | "739c1af56dae621aedf1bb282025a0d676eff713"))) 20 | 21 | (deftest test-procure 22 | (let [wt1 (gl/procure repo-url 'org.clojure/spec.alpha "739c1af") 23 | wt2 (gl/procure repo-url 'org.clojure/spec.alpha "6a56327")] 24 | (is (.exists (jio/file (gl/cache-dir) "_repos" "https" "github.com" "clojure" "spec.alpha"))) 25 | (is (= wt1 (.getAbsolutePath (jio/file (gl/cache-dir) "libs" "org.clojure" "spec.alpha" "739c1af56dae621aedf1bb282025a0d676eff713")))) 26 | (is (= wt2 (.getAbsolutePath (jio/file (gl/cache-dir) "libs" "org.clojure" "spec.alpha" "6a56327446c909db0d11ecf93a3c3d659b739be9")))))) 27 | 28 | (deftest test-descendant-fixed 29 | (is (= (gl/descendant repo-url ["607aef0" "739c1af"]) 30 | "739c1af56dae621aedf1bb282025a0d676eff713")) 31 | (is (= (gl/descendant repo-url ["739c1af" "607aef0"]) 32 | "739c1af56dae621aedf1bb282025a0d676eff713")) 33 | (is (= (gl/descendant repo-url ["607aef0" "607aef0"]) 34 | "607aef0643f6cf920293130d45e6160d93fda908")) 35 | 36 | (is (nil? (gl/descendant repo-url nil))) 37 | (is (nil? (gl/descendant repo-url []))) 38 | (is (nil? (gl/descendant repo-url ["abcdef" "123456"])))) 39 | 40 | (deftest test-descendant-combos 41 | (let [m (gl/resolve repo-url "master") 42 | m' (gl/resolve repo-url "master~1") 43 | m'' (gl/resolve repo-url "master~2")] 44 | (are [rs d] (= d (gl/descendant repo-url rs)) 45 | [m] m 46 | [m m''] m 47 | [m' m''] m' 48 | [m'' m' m] m))) 49 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | tools.gitlibs 4 | 2.6.207-SNAPSHOT 5 | tools.gitlibs 6 | API for retrieving, caching, and programatically accessing git libraries from Clojure. 7 | 8 | 9 | org.clojure 10 | pom.contrib 11 | 1.3.0 12 | 13 | 14 | 15 | 16 | puredanger 17 | Alex Miller 18 | 19 | 20 | 21 | 22 | true 23 | 1.11.4 24 | 25 | 26 | 27 | 28 | org.clojure 29 | clojure 30 | ${clojure.version} 31 | provided 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | com.theoryinpractise 42 | clojure-maven-plugin 43 | 1.7.1 44 | true 45 | 46 | ${clojure.warnOnReflection} 47 | true 48 | 49 | 50 | 51 | clojure-compile 52 | none 53 | 54 | 55 | clojure-test 56 | test 57 | 58 | test 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | scm:git:git@github.com:clojure/tools.gitlibs.git 68 | scm:git:git@github.com:clojure/tools.gitlibs.git 69 | git@github.com:clojure/tools.gitlibs.git 70 | HEAD 71 | 72 | 73 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Changelog 2 | =========== 3 | 4 | * 2.6.206 on Dec 5, 2024 5 | * Bump clojure dep to 1.11.4 6 | * Improve error message when clone fails to include url 7 | * 2.5.197 on May 31, 2023 8 | * TDEPS-248 - Make `tags` return known tags when offline 9 | * 2.5.190 on Feb 12, 2023 10 | * Don't use future to background the process reading (leaves non-daemon thread) 11 | * 2.5.186 on Feb 11, 2023 12 | * Don't block on big git output 13 | * 2.4.181 on Jun 19, 2022 14 | * Sort tags in version order 15 | * 2.4.176 on Jun 16, 2022 16 | * Add `commit-sha` api function to return commit sha for rev 17 | * 2.4.172 on Nov 8, 2021 18 | * TDEPS-212 - Support local file repos 19 | * 2.3.167 on Apr 22, 2021 20 | * Remove use of `--prune-tags` with `git fetch` as that was only added in git 2.17.0 21 | * 2.3.161 on Apr 9, 2021 22 | * Add new `object-type` api - takes rev, returns object type 23 | * 2.2.156 on Apr 7, 2021 24 | * `tags` api should fetch to ensure all tags are returned 25 | * 2.2.152 on Apr 3, 2021 26 | * Fix issue with fetching new commits on branches 27 | * 2.1.144 on Mar 12, 2021 28 | * Fix rev-parse check on unfetched sha to report failure 29 | * 2.1.139 on Mar 11, 2021 30 | * Add tags method 31 | * 2.1.129 on Mar 10, 2021 32 | * Change git options during checkout to work with more git versions 33 | * Check exit code on checkout and throw if failed 34 | * Overhaul config and debug settings 35 | * Change min Clojure dep to 1.9 36 | * 2.0.119 on Mar 10, 2021 37 | * Fix issues with checkouts of multiple commits per repo 38 | * resolve now only fetches if it can't resolve a ref 39 | * Config read from most to least preferred: Java system property / env var / default: 40 | * gitlibs dir: `clojure.gitlibs.dir` / `GITLIBS` / `nil` 41 | * git command: `clojure.gitlibs.command` / `GITLIBS_COMMAND` / `"git"` 42 | * Fix reflection error 43 | * 2.0.109 on Mar 3, 2021 44 | * TDEPS-91 Replace jgit implementation by shelling out to git 45 | * 1.0.100 on Aug 20, 2020 46 | * Fetch all tags on procure 47 | * 1.0.96 on Aug 7, 2020 48 | * TDEPS-160 - Add missing compression lib for ssh compression 49 | * 1.0.91 on June 9, 2020 50 | * Fix reflection warning 51 | * 1.0.83 on Feb 18, 2020 52 | * 0.2.64 on Mar 16, 2018 53 | * TDEPS-53 If cached gitlib dir is corrupt, re-clone 54 | * 0.2.59 on Feb 9, 2018 55 | * Add `cache-dir` API function 56 | * 0.2.54 on Jan 10, 2018 57 | * Make gitlibs cache dir configurable via environment variable GITLIBS 58 | * 0.2.47 on Jan 8, 2018 59 | * Bump jgit to latest release 60 | * In procure, use prefix to find working tree before needing to clone 61 | * 0.2.40 on Jan 4, 2018 62 | * Add tests 63 | * Fix descendant comparator order 64 | * 0.2.32 on Jan 3, 2018 65 | * Clean up initial API 66 | * Add clone / checkout print to console 67 | * Fix bug with fetching new commits on existing repos 68 | * 0.1.8 on Jan 2, 2018 69 | * Initial release 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | tools.gitlibs 2 | ======================================== 3 | 4 | An API for retrieving, caching, and programatically accessing git libraries. 5 | 6 | ## Rationale 7 | 8 | To access git dependencies (for example, via tools.deps), one must download git directories 9 | and working trees as indicated by git shas. This library provides this functionality and also 10 | keeps a cache of git dirs and working trees that can be reused. 11 | 12 | ## API 13 | 14 | The following API is provided in `clojure.tools.gitlibs`: 15 | 16 | * `(resolve git-url rev) ;; returns full sha of rev in git-url` 17 | * `(procure git-url lib rev) ;; returns working tree directory for git-url identified as lib at rev` 18 | * `(descendant git-url revs) ;; returns rev which is a descedant of all revs, or nil if none` 19 | * `(tags git-url) ;; returns a collection of tags in this git-url (fetches to refresh)` 20 | * `(cache-dir) ;; returns path to root of gitlibs cache dir` 21 | 22 | ### Git urls 23 | 24 | The following git url types are supported: 25 | 26 | * `https` - for public anonymous clone and fetch of public or private repos with credentials via git credential sources 27 | * `ssh` - for authenticated clone and fetch of private repos (uses ssh) 28 | * `http` and `git` protocols are plain-text and NOT supported or recommended 29 | 30 | ### Revs 31 | 32 | The API functions all take revs, which can be any git rev that resolves to a commit, such as: 33 | 34 | * Full sha (40 chars) 35 | * Prefix sha (sufficiently unique in the repo, often 7 chars) 36 | * Tag name 37 | * Branch name 38 | 39 | Procured working trees are always cached on the basis of the rev's full sha, so using `procure` 40 | repeatedly on a rev that does not resolve to a fixed sha may result in new checkouts in the cache. 41 | 42 | ### Configuration 43 | 44 | Downloaded git dirs and working trees are stored in the gitlibs cache dir, ~/.gitlibs by default. This directory is just a cache and can be safely removed if needed. 45 | 46 | tools.gitlibs can be configured by either environment variable or Java system property. If both are provided, the Java system property takes precedence. 47 | 48 | | Env var | Java system property | default | description 49 | | ------- | -------------------- | ------- | ----------- 50 | | GITLIBS | clojure.gitlibs.dir | ~/.gitlibs | Local directory cache for git repos and working trees | 51 | | GITLIBS_COMMAND | clojure.gitlibs.command | git | git command to run when shelling out (supply full path if needed) | 52 | | GITLIBS_DEBUG | clojure.gitlibs.debug | false | If true, print git commands and output to stderr | 53 | | GITLIBS_TERMINAL | clojure.gitlibs.terminal | false | If true, interactively prompt if needed | 54 | 55 | ## Example Usage 56 | 57 | ```clojure 58 | (require '[clojure.tools.gitlibs :as gl]) 59 | 60 | ;; Given a git repo url and a rev, resolve to a full sha. 61 | (gl/resolve "https://github.com/clojure/spec.alpha.git" "739c1af") 62 | ;; => "739c1af56dae621aedf1bb282025a0d676eff713" 63 | 64 | ;; Given a git repo url, library identifier, and a rev, return a path to the working tree 65 | (gl/procure "https://github.com/clojure/spec.alpha.git" 'org.clojure/spec.alpha "739c1af") 66 | ;; => "/Users/me/.gitlibs/libs/org.clojure/spec.alpha/739c1af56dae621aedf1bb282025a0d676eff713" 67 | 68 | ;; Given git repo url, and a collection of revs, return the full sha of the one commit that is 69 | ;; a descendant of all other revs or nil if no such rev exists in the collection. 70 | (gl/descendant "https://github.com/clojure/spec.alpha.git" ["607aef0" "739c1af"]) 71 | ;; => "739c1af56dae621aedf1bb282025a0d676eff713" 72 | ``` 73 | 74 | ## Release Information 75 | 76 | This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository. 77 | 78 | Latest release: 2.6.206 79 | 80 | * [All released versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22tools.gitlibs%22) 81 | * Coordinates: `org.clojure/tools.gitlibs {:mvn/version "2.6.206"}` 82 | 83 | # Developer Information 84 | 85 | * [GitHub project](https://github.com/clojure/tools.gitlibs) 86 | * [Bug Tracker](https://dev.clojure.org/jira/browse/TDEPS) - if you don't have an acct there, please ask at [Ask Clojure](https://ask.clojure.org) 87 | * [How to contribute](https://clojure.org/dev/dev) 88 | * [Continuous Integration](https://github.com/clojure/tools.gitlibs/actions/workflows/test.yml) 89 | 90 | # Copyright and License 91 | 92 | Copyright © Rich Hickey, Alex Miller, and contributors 93 | 94 | All rights reserved. The use and 95 | distribution terms for this software are covered by the 96 | [Eclipse Public License 1.0] which can be found in the file 97 | epl-v10.html at the root of this distribution. By using this software 98 | in any fashion, you are agreeing to be bound by the terms of this 99 | license. You must not remove this notice, or any other, from this 100 | software. 101 | 102 | [Eclipse Public License 1.0]: https://opensource.org/license/epl-1-0/ 103 | -------------------------------------------------------------------------------- /src/main/clojure/clojure/tools/gitlibs.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.tools.gitlibs 10 | "An API for retrieving and caching git repos and working trees. 11 | 12 | The git url can be either an https url for anonymous checkout or an ssh url 13 | for private access. revs can be either full sha, prefix sha, or tag name." 14 | (:refer-clojure :exclude [resolve]) 15 | (:require 16 | [clojure.java.io :as jio] 17 | [clojure.tools.gitlibs.config :as config] 18 | [clojure.tools.gitlibs.impl :as impl])) 19 | 20 | (set! *warn-on-reflection* true) 21 | 22 | (defn cache-dir 23 | "Return the root gitlibs cache directory. By default ~/.gitlibs or 24 | override by setting the environment variable GITLIBS." 25 | [] 26 | (:gitlibs/dir @config/CONFIG)) 27 | 28 | ;; Possible new API, internal for now 29 | (defn- resolve-all 30 | "Takes a git url and a coll of revs, and returns the full commit shas. 31 | Each rev may be a partial sha, full sha, or tag name. Returns nil for 32 | unresolveable revs." 33 | [url revs] 34 | (let [git-dir (impl/ensure-git-dir url)] 35 | (reduce 36 | (fn [rs r] 37 | (if-let [res (impl/git-rev-parse git-dir r)] 38 | (conj rs res) 39 | (do ;; could not resolve - fetch and try again 40 | (impl/git-fetch (jio/file git-dir)) 41 | (conj rs (impl/git-rev-parse git-dir r))))) 42 | [] revs))) 43 | 44 | (defn resolve 45 | "Takes a git url and a rev, and returns the full commit sha or nil if can't 46 | resolve. rev may be a partial sha, full sha, or tag name." 47 | [url rev] 48 | (first (resolve-all url [rev]))) 49 | 50 | (defn object-type 51 | "Takes a git url and rev, and returns the object type, one of :tag :tree 52 | :commit or :blob, or nil if not known or ambiguous." 53 | [url rev] 54 | (let [git-dir (impl/ensure-git-dir url)] 55 | (if-let [type (impl/git-type git-dir rev)] 56 | type 57 | (do 58 | (impl/git-fetch (jio/file git-dir)) 59 | (impl/git-type git-dir rev))))) 60 | 61 | (defn procure 62 | "Procure a working tree at rev for the git url representing the library lib, 63 | returns the directory path. lib is a qualified symbol where the qualifier is a 64 | controlled or conveyed identity, or nil if rev is unknown." 65 | [url lib rev] 66 | (let [lib-dir (impl/lib-dir lib) 67 | git-dir-path (impl/ensure-git-dir url) 68 | sha (or (impl/match-exact lib-dir rev) (impl/match-prefix lib-dir rev) (resolve url rev))] 69 | (when sha 70 | (let [sha-dir (jio/file lib-dir sha)] 71 | (when-not (.exists sha-dir) 72 | (impl/printerrln "Checking out:" url "at" rev) 73 | (impl/git-checkout git-dir-path lib-dir sha)) 74 | (.getCanonicalPath sha-dir))))) 75 | 76 | (defn descendant 77 | "Returns rev in git url which is a descendant of all other revs, 78 | or nil if no such relationship can be established." 79 | [url revs] 80 | (when (seq revs) 81 | (let [shas (resolve-all url revs)] 82 | (if (seq (filter nil? shas)) 83 | nil ;; can't resolve all shas in this repo 84 | (let [git-dir (impl/ensure-git-dir url)] 85 | (->> shas (sort (partial impl/commit-comparator git-dir)) first)))))) 86 | 87 | (defn tags 88 | "Fetches, then returns coll of tags in git url" 89 | [url] 90 | (impl/tags (impl/ensure-git-dir url))) 91 | 92 | (defn commit-sha 93 | "Returns unpeeled full commit sha, given a rev (which may be tag, branch, etc)" 94 | [url rev] 95 | (impl/git-rev-parse (impl/ensure-git-dir url) rev)) 96 | 97 | (comment 98 | (commit-sha "https://github.com/clojure/tools.build.git" "v0.8.2") 99 | 100 | (System/setProperty "clojure.gitlibs.debug" "true") 101 | (resolve "git@github.com:clojure/tools.gitlibs.git" "11fc774") 102 | (descendant "https://github.com/clojure/tools.gitlibs.git" ["5e2797a487c" "11fc774" "d82adc29" "815e312310"]) 103 | 104 | (println 105 | @(future (procure "https://github.com/clojure/tools.gitlibs.git" 'org.clojure/tools.gitlibs "11fc77496f013871c8af3514bbba03de0af28061")) 106 | @(future (procure "https://github.com/clojure/tools.gitlibs.git" 'org.clojure/tools.gitlibs "11fc77496f013871c8af3514bbba03de0af28061"))) 107 | 108 | (println 109 | @(future (procure "https://github.com/cognitect-labs/test-runner.git" 'cognitect-labs/test-runner "b6b3193fcc42659d7e46ecd1884a228993441182")) 110 | @(future (procure "https://github.com/cognitect-labs/test-runner.git" 'cognitect-labs/test-runner "cb96e80f6f3d3b307c59cbeb49bb0dcb3a2a780b")) 111 | @(future (procure "https://github.com/cognitect-labs/test-runner.git" 'cognitect-labs/test-runner "9e1098965f2089c8cf492d23c0b7520f8690440a"))) 112 | 113 | (tags "https://github.com/clojure/tools.gitlibs.git") 114 | 115 | ;; big output 116 | (tags "https://github.com/confluentinc/kafka-streams-examples.git") 117 | ) 118 | -------------------------------------------------------------------------------- /src/main/clojure/clojure/tools/gitlibs/impl.clj: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Rich Hickey. All rights reserved. 2 | ; The use and distribution terms for this software are covered by the 3 | ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 4 | ; which can be found in the file epl-v10.html at the root of this distribution. 5 | ; By using this software in any fashion, you are agreeing to be bound by 6 | ; the terms of this license. 7 | ; You must not remove this notice, or any other, from this software. 8 | 9 | (ns clojure.tools.gitlibs.impl 10 | "Implementation, use at your own risk" 11 | (:require 12 | [clojure.java.io :as jio] 13 | [clojure.string :as str] 14 | [clojure.tools.gitlibs.config :as config]) 15 | (:import 16 | [java.lang ProcessBuilder$Redirect] 17 | [java.io File FilenameFilter InputStream IOException StringWriter])) 18 | 19 | (set! *warn-on-reflection* true) 20 | 21 | ;; io util 22 | 23 | (defn printerrln [& msgs] 24 | (binding [*out* *err*] 25 | (apply println msgs))) 26 | 27 | (defn- capture 28 | "Reads from input-stream until EOF and returns a String (or nil if 0 length)." 29 | [^InputStream input-stream] 30 | (let [writer (StringWriter.)] 31 | (jio/copy input-stream writer) 32 | (let [s (str/trim (.toString writer))] 33 | (when-not (zero? (.length s)) 34 | s)))) 35 | 36 | (defmacro background 37 | [& body] 38 | `(let [result# (promise)] 39 | (doto (Thread. (fn [] (deliver result# (do ~@body)))) 40 | (.setDaemon true) 41 | (.start)) 42 | result#)) 43 | 44 | (defn- run-git 45 | [& args] 46 | (let [{:gitlibs/keys [command debug terminal]} @config/CONFIG 47 | command-args (cons command args)] 48 | (when debug 49 | (apply printerrln command-args)) 50 | (let [proc-builder (ProcessBuilder. ^java.util.List command-args) 51 | _ (when debug (.redirectError proc-builder ProcessBuilder$Redirect/INHERIT)) 52 | _ (when-not terminal (.put (.environment proc-builder) "GIT_TERMINAL_PROMPT" "0")) 53 | proc (.start proc-builder) 54 | out (background (capture (.getInputStream proc))) 55 | err (background (capture (.getErrorStream proc))) ;; if debug is true, stderr will be redirected instead 56 | exit (.waitFor proc)] 57 | {:args command-args, :exit exit, :out @out, :err @err}))) 58 | 59 | ;; dirs 60 | 61 | (defn lib-dir 62 | ^File [lib] 63 | (jio/file (:gitlibs/dir @config/CONFIG) "libs" (namespace lib) (name lib))) 64 | 65 | (def ^:private git-url-regex 66 | #"([a-z0-9+.-]+):\/\/(?:(?:(?:[^@]+?)@)?([^/]+?)(?::[0-9]*)?)?(/[^:]+)") 67 | 68 | (def ^:private git-scp-regex 69 | #"(?:(?:[^@]+?)@)?(.+?):([^:]+)") 70 | 71 | (defn- clean-url 72 | "Convert url into a safe relative path (this is not a reversible transformation) 73 | based on scheme, host, and path (drop user and port). 74 | 75 | Examples: 76 | ssh://git@gitlab.com:3333/org/repo.git => ssh/gitlab.com/org/repo 77 | git@github.com:dotted.org/dotted.repo.git => ssh/github.com/dotted.org/dotted.repo 78 | file://../foo => file/REL/_DOTDOT_/foo 79 | file:///Users/user/foo.git => file/Users/user/foo 80 | ../foo => file/REL/_DOTDOT_/foo 81 | ~user/foo.git => file/REL/_TILDE_user/foo 82 | 83 | * https://git-scm.com/docs/git-clone#_git_urls 84 | * https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols 85 | " 86 | [url] 87 | (let [[scheme host path] (cond 88 | (str/starts-with? url "file://") ["file" nil (-> url (subs 7) (str/replace #"^([^/])" "REL/$1"))] 89 | (str/includes? url "://") (let [[_ s h p] (re-matches git-url-regex url)] [s h p]) 90 | (str/includes? url ":") (let [[_ h p] (re-matches git-scp-regex url)] ["ssh" h p]) 91 | :local-repo ["file" nil (str/replace url #"^([^/])" "REL/$1")]) 92 | clean-path (-> path 93 | (str/replace #"\.git/?$" "") ;; remove trailing .git or .git/ 94 | (str/replace #"~" "_TILDE_")) ;; replace ~ with _TILDE_ 95 | dir-parts (->> (concat [scheme host] (str/split clean-path #"/")) ;; split on / 96 | (remove str/blank?) ;; remove any missing path segments 97 | (map #(-> % ({"." "_DOT_", ".." "_DOTDOT_"} %))))] ;; replace . or .. segments 98 | (str/join "/" dir-parts))) 99 | 100 | (defn git-dir 101 | ^File [url] 102 | (jio/file (:gitlibs/dir @config/CONFIG) "_repos" (clean-url url))) 103 | 104 | (defn git-try-fetch 105 | "Try to fetch and return the error code (0=success)" 106 | [^File git-dir] 107 | (let [git-path (.getCanonicalPath git-dir) 108 | ;; NOTE: --prune-tags would be desirable here but was added in git 2.17.0 109 | {:keys [exit]} (run-git "--git-dir" git-path 110 | "fetch" "--quiet" "--all" "--tags" "--prune")] 111 | exit)) 112 | 113 | (defn git-fetch 114 | [^File git-dir] 115 | (let [git-path (.getCanonicalPath git-dir) 116 | ;; NOTE: --prune-tags would be desirable here but was added in git 2.17.0 117 | {:keys [exit err] :as ret} (run-git "--git-dir" git-path 118 | "fetch" "--quiet" "--all" "--tags" "--prune")] 119 | (when-not (zero? exit) 120 | (throw (ex-info (format "Unable to fetch %s%n%s" git-path err) ret))))) 121 | 122 | ;; TODO: restrict clone to an optional refspec? 123 | (defn git-clone-bare 124 | [url ^File git-dir] 125 | (printerrln "Cloning:" url) 126 | (let [git-path (.getCanonicalPath git-dir) 127 | {:keys [exit err] :as ret} (run-git "clone" "--quiet" "--mirror" url git-path)] 128 | (when-not (zero? exit) 129 | (throw (ex-info (format "Unable to clone %s to %s:%n%s" url git-path err) ret))) 130 | git-dir)) 131 | 132 | (defn ensure-git-dir 133 | "Ensure the bare git dir for the specified url, return the path to the git dir." 134 | [url] 135 | (let [git-dir-file (git-dir url) 136 | config-file (jio/file git-dir-file "config")] 137 | (when-not (.exists config-file) 138 | (git-clone-bare url git-dir-file)) 139 | (.getCanonicalPath git-dir-file))) 140 | 141 | (defn git-checkout 142 | [git-dir-path ^File lib-dir ^String rev] 143 | (let [rev-file (jio/file lib-dir rev)] 144 | (when-not (.exists rev-file) 145 | (let [{:keys [exit err] :as ret} 146 | (run-git "--git-dir" git-dir-path 147 | "worktree" "add" "--force" "--detach" 148 | (.getCanonicalPath rev-file) rev)] 149 | (when-not (zero? exit) 150 | (throw (ex-info (format "Unable to checkout %s%n%s" rev err) ret))))))) 151 | 152 | (defn git-rev-parse 153 | [git-dir rev] 154 | (let [{:keys [exit out]} (run-git "--git-dir" git-dir "rev-parse" (str rev "^{commit}"))] 155 | (when (zero? exit) 156 | (str/trimr out)))) 157 | 158 | (defn git-type 159 | [git-dir rev] 160 | (let [{:keys [exit out]} (run-git "--git-dir" git-dir "cat-file" "-t" rev)] 161 | (when (zero? exit) 162 | (keyword (str/trimr out))))) 163 | 164 | ;; git merge-base --is-ancestor 165 | (defn- ancestor? 166 | [git-dir x y] 167 | (let [{:keys [exit err] :as ret} (run-git "--git-dir" git-dir "merge-base" "--is-ancestor" x y)] 168 | (condp = exit 169 | 0 true 170 | 1 false 171 | (throw (ex-info (format "Unable to compare commits %s%n%s" git-dir err) ret))))) 172 | 173 | (defn commit-comparator 174 | [git-dir x y] 175 | (cond 176 | (= x y) 0 177 | (ancestor? git-dir x y) 1 178 | (ancestor? git-dir y x) -1 179 | :else (throw (ex-info "" {})))) 180 | 181 | (defn match-exact 182 | "In dir, match file in dir with exact, nil if doesn't exist" 183 | [^File dir exact] 184 | (when (.exists (jio/file dir exact)) 185 | exact)) 186 | 187 | (defn match-prefix 188 | "In dir, match file in dir with prefix, nil if not found, exception if more than one." 189 | [^File dir prefix] 190 | (when (.exists dir) 191 | (if (.exists (jio/file dir prefix)) 192 | prefix 193 | (let [matches (.listFiles dir 194 | (reify FilenameFilter 195 | (accept [_this _dir name] 196 | (str/starts-with? name prefix))))] 197 | (case (alength matches) 198 | 0 nil 199 | 1 (.getName ^File (aget matches 0)) 200 | (throw (IOException. (str "Prefix not unique: " prefix)))))))) 201 | 202 | (defn tags 203 | "Fetch, then return all tags in the git dir." 204 | [git-dir] 205 | (git-try-fetch (jio/file git-dir)) 206 | (let [{:keys [exit out err] :as ret} (run-git "--git-dir" git-dir "tag" "--sort=v:refname")] 207 | (when-not (zero? exit) 208 | (throw (ex-info (format "Unable to get tags %s%n%s" git-dir err) ret))) 209 | (remove str/blank? (str/split-lines out)))) 210 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' 19 | from a Contributor if it was added to the Program by such Contributor 20 | itself or anyone acting on such Contributor's behalf. Contributions do not 21 | include additions to the Program which: (i) are separate modules of 22 | software distributed in conjunction with the Program under their own 23 | license agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this 32 | Agreement. 33 | 34 | "Recipient" means anyone who receives the Program under this Agreement, 35 | including all Contributors. 36 | 37 | 2. GRANT OF RIGHTS 38 | a) Subject to the terms of this Agreement, each Contributor hereby grants 39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 40 | reproduce, prepare derivative works of, publicly display, publicly 41 | perform, distribute and sublicense the Contribution of such Contributor, 42 | if any, and such derivative works, in source code and object code form. 43 | b) Subject to the terms of this Agreement, each Contributor hereby grants 44 | Recipient a non-exclusive, worldwide, royalty-free patent license under 45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 46 | transfer the Contribution of such Contributor, if any, in source code and 47 | object code form. This patent license shall apply to the combination of 48 | the Contribution and the Program if, at the time the Contribution is 49 | added by the Contributor, such addition of the Contribution causes such 50 | combination to be covered by the Licensed Patents. The patent license 51 | shall not apply to any other combinations which include the Contribution. 52 | No hardware per se is licensed hereunder. 53 | c) Recipient understands that although each Contributor grants the licenses 54 | to its Contributions set forth herein, no assurances are provided by any 55 | Contributor that the Program does not infringe the patent or other 56 | intellectual property rights of any other entity. Each Contributor 57 | disclaims any liability to Recipient for claims brought by any other 58 | entity based on infringement of intellectual property rights or 59 | otherwise. As a condition to exercising the rights and licenses granted 60 | hereunder, each Recipient hereby assumes sole responsibility to secure 61 | any other intellectual property rights needed, if any. For example, if a 62 | third party patent license is required to allow Recipient to distribute 63 | the Program, it is Recipient's responsibility to acquire that license 64 | before distributing the Program. 65 | d) Each Contributor represents that to its knowledge it has sufficient 66 | copyright rights in its Contribution, if any, to grant the copyright 67 | license set forth in this Agreement. 68 | 69 | 3. REQUIREMENTS 70 | 71 | A Contributor may choose to distribute the Program in object code form under 72 | its own license agreement, provided that: 73 | 74 | a) it complies with the terms and conditions of this Agreement; and 75 | b) its license agreement: 76 | i) effectively disclaims on behalf of all Contributors all warranties 77 | and conditions, express and implied, including warranties or 78 | conditions of title and non-infringement, and implied warranties or 79 | conditions of merchantability and fitness for a particular purpose; 80 | ii) effectively excludes on behalf of all Contributors all liability for 81 | damages, including direct, indirect, special, incidental and 82 | consequential damages, such as lost profits; 83 | iii) states that any provisions which differ from this Agreement are 84 | offered by that Contributor alone and not by any other party; and 85 | iv) states that source code for the Program is available from such 86 | Contributor, and informs licensees how to obtain it in a reasonable 87 | manner on or through a medium customarily used for software exchange. 88 | 89 | When the Program is made available in source code form: 90 | 91 | a) it must be made available under this Agreement; and 92 | b) a copy of this Agreement must be included with each copy of the Program. 93 | Contributors may not remove or alter any copyright notices contained 94 | within the Program. 95 | 96 | Each Contributor must identify itself as the originator of its Contribution, 97 | if 98 | any, in a manner that reasonably allows subsequent Recipients to identify the 99 | originator of the Contribution. 100 | 101 | 4. COMMERCIAL DISTRIBUTION 102 | 103 | Commercial distributors of software may accept certain responsibilities with 104 | respect to end users, business partners and the like. While this license is 105 | intended to facilitate the commercial use of the Program, the Contributor who 106 | includes the Program in a commercial product offering should do so in a manner 107 | which does not create potential liability for other Contributors. Therefore, 108 | if a Contributor includes the Program in a commercial product offering, such 109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 110 | every other Contributor ("Indemnified Contributor") against any losses, 111 | damages and costs (collectively "Losses") arising from claims, lawsuits and 112 | other legal actions brought by a third party against the Indemnified 113 | Contributor to the extent caused by the acts or omissions of such Commercial 114 | Contributor in connection with its distribution of the Program in a commercial 115 | product offering. The obligations in this section do not apply to any claims 116 | or Losses relating to any actual or alleged intellectual property 117 | infringement. In order to qualify, an Indemnified Contributor must: 118 | a) promptly notify the Commercial Contributor in writing of such claim, and 119 | b) allow the Commercial Contributor to control, and cooperate with the 120 | Commercial Contributor in, the defense and any related settlement 121 | negotiations. The Indemnified Contributor may participate in any such claim at 122 | its own expense. 123 | 124 | For example, a Contributor might include the Program in a commercial product 125 | offering, Product X. That Contributor is then a Commercial Contributor. If 126 | that Commercial Contributor then makes performance claims, or offers 127 | warranties related to Product X, those performance claims and warranties are 128 | such Commercial Contributor's responsibility alone. Under this section, the 129 | Commercial Contributor would have to defend claims against the other 130 | Contributors related to those performance claims and warranties, and if a 131 | court requires any other Contributor to pay any damages as a result, the 132 | Commercial Contributor must pay those damages. 133 | 134 | 5. NO WARRANTY 135 | 136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 140 | Recipient is solely responsible for determining the appropriateness of using 141 | and distributing the Program and assumes all risks associated with its 142 | exercise of rights under this Agreement , including but not limited to the 143 | risks and costs of program errors, compliance with applicable laws, damage to 144 | or loss of data, programs or equipment, and unavailability or interruption of 145 | operations. 146 | 147 | 6. DISCLAIMER OF LIABILITY 148 | 149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 156 | OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | 160 | If any provision of this Agreement is invalid or unenforceable under 161 | applicable law, it shall not affect the validity or enforceability of the 162 | remainder of the terms of this Agreement, and without further action by the 163 | parties hereto, such provision shall be reformed to the minimum extent 164 | necessary to make such provision valid and enforceable. 165 | 166 | If Recipient institutes patent litigation against any entity (including a 167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 168 | (excluding combinations of the Program with other software or hardware) 169 | infringes such Recipient's patent(s), then such Recipient's rights granted 170 | under Section 2(b) shall terminate as of the date such litigation is filed. 171 | 172 | All Recipient's rights under this Agreement shall terminate if it fails to 173 | comply with any of the material terms or conditions of this Agreement and does 174 | not cure such failure in a reasonable period of time after becoming aware of 175 | such noncompliance. If all Recipient's rights under this Agreement terminate, 176 | Recipient agrees to cease use and distribution of the Program as soon as 177 | reasonably practicable. However, Recipient's obligations under this Agreement 178 | and any licenses granted by Recipient relating to the Program shall continue 179 | and survive. 180 | 181 | Everyone is permitted to copy and distribute copies of this Agreement, but in 182 | order to avoid inconsistency the Agreement is copyrighted and may only be 183 | modified in the following manner. The Agreement Steward reserves the right to 184 | publish new versions (including revisions) of this Agreement from time to 185 | time. No one other than the Agreement Steward has the right to modify this 186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 187 | Eclipse Foundation may assign the responsibility to serve as the Agreement 188 | Steward to a suitable separate entity. Each new version of the Agreement will 189 | be given a distinguishing version number. The Program (including 190 | Contributions) may always be distributed subject to the version of the 191 | Agreement under which it was received. In addition, after a new version of the 192 | Agreement is published, Contributor may elect to distribute the Program 193 | (including its Contributions) under the new version. Except as expressly 194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 195 | licenses to the intellectual property of any Contributor under this Agreement, 196 | whether expressly, by implication, estoppel or otherwise. All rights in the 197 | Program not expressly granted under this Agreement are reserved. 198 | 199 | This Agreement is governed by the laws of the State of New York and the 200 | intellectual property laws of the United States of America. No party to this 201 | Agreement will bring a legal action under this Agreement more than one year 202 | after the cause of action arose. Each party waives its rights to a jury trial in 203 | any resulting litigation. 204 | 205 | 206 | -------------------------------------------------------------------------------- /epl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Eclipse Public License - Version 1.0 8 | 25 | 26 | 27 | 28 | 29 | 30 |

Eclipse Public License - v 1.0

31 | 32 |

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 33 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR 34 | DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS 35 | AGREEMENT.

36 | 37 |

1. DEFINITIONS

38 | 39 |

"Contribution" means:

40 | 41 |

a) in the case of the initial Contributor, the initial 42 | code and documentation distributed under this Agreement, and

43 |

b) in the case of each subsequent Contributor:

44 |

i) changes to the Program, and

45 |

ii) additions to the Program;

46 |

where such changes and/or additions to the Program 47 | originate from and are distributed by that particular Contributor. A 48 | Contribution 'originates' from a Contributor if it was added to the 49 | Program by such Contributor itself or anyone acting on such 50 | Contributor's behalf. Contributions do not include additions to the 51 | Program which: (i) are separate modules of software distributed in 52 | conjunction with the Program under their own license agreement, and (ii) 53 | are not derivative works of the Program.

54 | 55 |

"Contributor" means any person or entity that distributes 56 | the Program.

57 | 58 |

"Licensed Patents" mean patent claims licensable by a 59 | Contributor which are necessarily infringed by the use or sale of its 60 | Contribution alone or when combined with the Program.

61 | 62 |

"Program" means the Contributions distributed in accordance 63 | with this Agreement.

64 | 65 |

"Recipient" means anyone who receives the Program under 66 | this Agreement, including all Contributors.

67 | 68 |

2. GRANT OF RIGHTS

69 | 70 |

a) Subject to the terms of this Agreement, each 71 | Contributor hereby grants Recipient a non-exclusive, worldwide, 72 | royalty-free copyright license to reproduce, prepare derivative works 73 | of, publicly display, publicly perform, distribute and sublicense the 74 | Contribution of such Contributor, if any, and such derivative works, in 75 | source code and object code form.

76 | 77 |

b) Subject to the terms of this Agreement, each 78 | Contributor hereby grants Recipient a non-exclusive, worldwide, 79 | royalty-free patent license under Licensed Patents to make, use, sell, 80 | offer to sell, import and otherwise transfer the Contribution of such 81 | Contributor, if any, in source code and object code form. This patent 82 | license shall apply to the combination of the Contribution and the 83 | Program if, at the time the Contribution is added by the Contributor, 84 | such addition of the Contribution causes such combination to be covered 85 | by the Licensed Patents. The patent license shall not apply to any other 86 | combinations which include the Contribution. No hardware per se is 87 | licensed hereunder.

88 | 89 |

c) Recipient understands that although each Contributor 90 | grants the licenses to its Contributions set forth herein, no assurances 91 | are provided by any Contributor that the Program does not infringe the 92 | patent or other intellectual property rights of any other entity. Each 93 | Contributor disclaims any liability to Recipient for claims brought by 94 | any other entity based on infringement of intellectual property rights 95 | or otherwise. As a condition to exercising the rights and licenses 96 | granted hereunder, each Recipient hereby assumes sole responsibility to 97 | secure any other intellectual property rights needed, if any. For 98 | example, if a third party patent license is required to allow Recipient 99 | to distribute the Program, it is Recipient's responsibility to acquire 100 | that license before distributing the Program.

101 | 102 |

d) Each Contributor represents that to its knowledge it 103 | has sufficient copyright rights in its Contribution, if any, to grant 104 | the copyright license set forth in this Agreement.

105 | 106 |

3. REQUIREMENTS

107 | 108 |

A Contributor may choose to distribute the Program in object code 109 | form under its own license agreement, provided that:

110 | 111 |

a) it complies with the terms and conditions of this 112 | Agreement; and

113 | 114 |

b) its license agreement:

115 | 116 |

i) effectively disclaims on behalf of all Contributors 117 | all warranties and conditions, express and implied, including warranties 118 | or conditions of title and non-infringement, and implied warranties or 119 | conditions of merchantability and fitness for a particular purpose;

120 | 121 |

ii) effectively excludes on behalf of all Contributors 122 | all liability for damages, including direct, indirect, special, 123 | incidental and consequential damages, such as lost profits;

124 | 125 |

iii) states that any provisions which differ from this 126 | Agreement are offered by that Contributor alone and not by any other 127 | party; and

128 | 129 |

iv) states that source code for the Program is available 130 | from such Contributor, and informs licensees how to obtain it in a 131 | reasonable manner on or through a medium customarily used for software 132 | exchange.

133 | 134 |

When the Program is made available in source code form:

135 | 136 |

a) it must be made available under this Agreement; and

137 | 138 |

b) a copy of this Agreement must be included with each 139 | copy of the Program.

140 | 141 |

Contributors may not remove or alter any copyright notices contained 142 | within the Program.

143 | 144 |

Each Contributor must identify itself as the originator of its 145 | Contribution, if any, in a manner that reasonably allows subsequent 146 | Recipients to identify the originator of the Contribution.

147 | 148 |

4. COMMERCIAL DISTRIBUTION

149 | 150 |

Commercial distributors of software may accept certain 151 | responsibilities with respect to end users, business partners and the 152 | like. While this license is intended to facilitate the commercial use of 153 | the Program, the Contributor who includes the Program in a commercial 154 | product offering should do so in a manner which does not create 155 | potential liability for other Contributors. Therefore, if a Contributor 156 | includes the Program in a commercial product offering, such Contributor 157 | ("Commercial Contributor") hereby agrees to defend and 158 | indemnify every other Contributor ("Indemnified Contributor") 159 | against any losses, damages and costs (collectively "Losses") 160 | arising from claims, lawsuits and other legal actions brought by a third 161 | party against the Indemnified Contributor to the extent caused by the 162 | acts or omissions of such Commercial Contributor in connection with its 163 | distribution of the Program in a commercial product offering. The 164 | obligations in this section do not apply to any claims or Losses 165 | relating to any actual or alleged intellectual property infringement. In 166 | order to qualify, an Indemnified Contributor must: a) promptly notify 167 | the Commercial Contributor in writing of such claim, and b) allow the 168 | Commercial Contributor to control, and cooperate with the Commercial 169 | Contributor in, the defense and any related settlement negotiations. The 170 | Indemnified Contributor may participate in any such claim at its own 171 | expense.

172 | 173 |

For example, a Contributor might include the Program in a commercial 174 | product offering, Product X. That Contributor is then a Commercial 175 | Contributor. If that Commercial Contributor then makes performance 176 | claims, or offers warranties related to Product X, those performance 177 | claims and warranties are such Commercial Contributor's responsibility 178 | alone. Under this section, the Commercial Contributor would have to 179 | defend claims against the other Contributors related to those 180 | performance claims and warranties, and if a court requires any other 181 | Contributor to pay any damages as a result, the Commercial Contributor 182 | must pay those damages.

183 | 184 |

5. NO WARRANTY

185 | 186 |

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 187 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 188 | OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 189 | ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY 190 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 191 | responsible for determining the appropriateness of using and 192 | distributing the Program and assumes all risks associated with its 193 | exercise of rights under this Agreement , including but not limited to 194 | the risks and costs of program errors, compliance with applicable laws, 195 | damage to or loss of data, programs or equipment, and unavailability or 196 | interruption of operations.

197 | 198 |

6. DISCLAIMER OF LIABILITY

199 | 200 |

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT 201 | NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, 202 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING 203 | WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF 204 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 205 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR 206 | DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 207 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

208 | 209 |

7. GENERAL

210 | 211 |

If any provision of this Agreement is invalid or unenforceable under 212 | applicable law, it shall not affect the validity or enforceability of 213 | the remainder of the terms of this Agreement, and without further action 214 | by the parties hereto, such provision shall be reformed to the minimum 215 | extent necessary to make such provision valid and enforceable.

216 | 217 |

If Recipient institutes patent litigation against any entity 218 | (including a cross-claim or counterclaim in a lawsuit) alleging that the 219 | Program itself (excluding combinations of the Program with other 220 | software or hardware) infringes such Recipient's patent(s), then such 221 | Recipient's rights granted under Section 2(b) shall terminate as of the 222 | date such litigation is filed.

223 | 224 |

All Recipient's rights under this Agreement shall terminate if it 225 | fails to comply with any of the material terms or conditions of this 226 | Agreement and does not cure such failure in a reasonable period of time 227 | after becoming aware of such noncompliance. If all Recipient's rights 228 | under this Agreement terminate, Recipient agrees to cease use and 229 | distribution of the Program as soon as reasonably practicable. However, 230 | Recipient's obligations under this Agreement and any licenses granted by 231 | Recipient relating to the Program shall continue and survive.

232 | 233 |

Everyone is permitted to copy and distribute copies of this 234 | Agreement, but in order to avoid inconsistency the Agreement is 235 | copyrighted and may only be modified in the following manner. The 236 | Agreement Steward reserves the right to publish new versions (including 237 | revisions) of this Agreement from time to time. No one other than the 238 | Agreement Steward has the right to modify this Agreement. The Eclipse 239 | Foundation is the initial Agreement Steward. The Eclipse Foundation may 240 | assign the responsibility to serve as the Agreement Steward to a 241 | suitable separate entity. Each new version of the Agreement will be 242 | given a distinguishing version number. The Program (including 243 | Contributions) may always be distributed subject to the version of the 244 | Agreement under which it was received. In addition, after a new version 245 | of the Agreement is published, Contributor may elect to distribute the 246 | Program (including its Contributions) under the new version. Except as 247 | expressly stated in Sections 2(a) and 2(b) above, Recipient receives no 248 | rights or licenses to the intellectual property of any Contributor under 249 | this Agreement, whether expressly, by implication, estoppel or 250 | otherwise. All rights in the Program not expressly granted under this 251 | Agreement are reserved.

252 | 253 |

This Agreement is governed by the laws of the State of New York and 254 | the intellectual property laws of the United States of America. No party 255 | to this Agreement will bring a legal action under this Agreement more 256 | than one year after the cause of action arose. Each party waives its 257 | rights to a jury trial in any resulting litigation.

258 | 259 | 260 | 261 | 262 | --------------------------------------------------------------------------------