diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 70fa2226..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @concourse/maintainers diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index d87b47a6..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: [taylorsilva] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index a4dce4c2..00000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,4 +0,0 @@ -template: | - ## What's Changed - - $CHANGES diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 65153700..00000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.swp -test/gpg/* diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5cc23044..00000000 --- a/Dockerfile +++ /dev/null @@ -1,71 +0,0 @@ -ARG base_image=cgr.dev/chainguard/wolfi-base:latest - -FROM ${base_image} AS proxytunnel -RUN apk --no-cache add \ - git \ - make \ - gcc \ - openssl-dev - -WORKDIR /root -RUN git clone https://github.com/proxytunnel/proxytunnel.git && \ - cd proxytunnel && \ - make -j4 - -FROM ${base_image} AS resource -COPY --from=proxytunnel /root/proxytunnel/proxytunnel /usr/bin/ - -# minimum dependencies we need for the resource -RUN apk --no-cache add \ - bash \ - ca-certificates \ - coreutils \ - curl \ - git \ - git-crypt \ - git-lfs \ - gnupg \ - gnupg-dirmngr \ - gpg \ - gpg-agent \ - jq \ - openssh-client \ - openssl - -RUN git config --global user.email "git@localhost" -RUN git config --global user.name "git" -RUN git config --global pull.rebase "false" -RUN git config --global protocol.file.allow "always" -RUN git config --global http.version "HTTP/2" - -# Remove unrelated git binaries we don't need -WORKDIR /usr/libexec/git-core -RUN rm -f \ - git-archimport \ - git-cvsexportcommit \ - git-cvsimport \ - git-cvsserver \ - git-svn \ - git-web--browse - -WORKDIR /usr/bin -RUN rm -f git-cvsserver - -WORKDIR /usr/share -RUN rm -rf locale - -ADD assets/ /opt/resource/ -RUN chmod +x /opt/resource/* - -FROM resource AS tests -RUN apk --no-cache add openssh-keygen -ADD test/ /tests -RUN /tests/all.sh - -FROM resource AS integrationtests -RUN apk --no-cache add iproute2 squid -ADD test/ /tests/test -ADD integration-tests /tests/integration-tests -RUN /tests/integration-tests/integration.sh - -FROM resource diff --git a/LICENSE b/LICENSE deleted file mode 100644 index e06d2081..00000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/NOTICE.md b/NOTICE.md deleted file mode 100644 index 02787fe8..00000000 --- a/NOTICE.md +++ /dev/null @@ -1,12 +0,0 @@ -Copyright 2014-2016 Alex Suraci, Chris Brown, and Pivotal Software, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. diff --git a/README.md b/README.md deleted file mode 100644 index cc0827af..00000000 --- a/README.md +++ /dev/null @@ -1,1049 +0,0 @@ -# Git Resource - -Tracks commits, tags, or branches in a [git](http://git-scm.com/) repository. - - - Build Status - - - -## Source Configuration - - - - - - - - - - -
Field NameDescription
version_type (Optional) -
    -
  • commits (Default): Resource will return commits from the specified branch. Can also be used to find tags on a branch.
  • -
  • tags: Resource will find matching tags from the git repo.
  • -
  • branches: Resource will return a list of branches from the git repo.
  • -
-
- -The following fields are used by all `version_type`'s. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field NameDescription
uri (Required)The location of the repository.
private_key (Optional)Private key to use when using an ssh@ format uri. Example: -
-private_key: |
-  -----BEGIN RSA PRIVATE KEY-----
-  ...
-  -----END RSA PRIVATE KEY-----
-      
-
private_key_user (Optional)Enables setting User in the ssh config.
private_key_passphrase (Optional)To unlock private_key if it is protected by a passphrase.
forward_agent (Optional)Enables ForwardAgent SSH option when set to true. Useful when using proxy/jump hosts. Defaults to false.
username (Optional)Username for HTTP(S) auth when pulling/pushing. This is needed when only HTTP/HTTPS protocol for git is available (which does not support private key auth) and auth is required.
github_app_id (Optional)GitHub App ID (or Client ID) to use to authenticate as.
github_app_private_key (Optional)GitHub App private key credential for generating access tokens.
github_app_org (Optional)Organization where GitHub App is installed.
github_app_user (Optional)User or owner of the repository where GitHub App is installed. If github_app_repo is not present, GitHub app is assumed to be installed on the user, otherwise it is assumed to be installed in the repository.
github_app_repo (Optional)Repository where GitHub App is installed. github_app_user must also be set.
password (Optional)Password for HTTP(S) auth when pulling/pushing.
credential_hosts (Optional)List of hostnames the HTTP(S) username/password may be sent to. When set, the credentials are written to .netrc scoped to these hosts instead of the default entry, which matches every host. Hosts are specified with no protocol, e.g. github.com. Submodules on hosts not listed here will not receive these credentials; use submodule_credentials for those. When omitted, credentials match all hosts (previous behavior).
skip_ssl_verification (Optional)Skips git ssl verification by exporting GIT_SSL_NO_VERIFY=true.
submodule_credentials (Optional)List of credentials for HTTP(s) or SSH auth when pulling git submodules which are not stored in the same git server as the container repository or are protected by a different private key. -
    -
  • http(s) credentials: -
      -
    • host : The host to connect to. Note that host is specified with no protocol extensions.
    • -
    • username : Username for HTTP(S) auth when pulling submodule.
    • -
    • password : Password for HTTP(S) auth when pulling submodule.
    • -
    -
  • -
  • ssh credentials: -
      -
    • url : Submodule url, as specified in the .gitmodule file. Support full or relative ssh url.
    • -
    • private_key : Private key for SSH auth when pulling submodule.
    • -
    • private_key_passphrase : Optional. To unlock private_key if it is protected by a passphrase.
    • -
    -
  • -
  • example: -
    -submodule_credentials:
    -  # http(s) credentials
    -- host: github.com
    -  username: git-user
    -  password: git-password
    -  # ssh credentials
    -- url: git@github.com:org-name/repo-name.git
    -  private_key: |
    -    -----BEGIN RSA PRIVATE KEY-----
    -    ...
    -    -----END RSA PRIVATE KEY-----
    -  private_key_passphrase: ssh-passphrase # (optional)
    -  # ssh credentials with relative url
    -- url: ../org-name/repo-name.git
    -  private_key: |
    -    -----BEGIN RSA PRIVATE KEY-----
    -    ...
    -    -----END RSA PRIVATE KEY-----
    -  private_key_passphrase: ssh-passphrase # (optional)
    -          
    -
  • -
-
git_config (Optional) - Specified as a list of pairs name and value. It will configure git global options, setting each name with each value. -

This can be useful to set options like credential.helper or similar.

-

See the git-config(1) manual page for more information and documentation of existing git options.

-

Example: -

-git_config:
-  - name: push.recurseSubmodules
-    value: "no"
-        
-

-
disable_ci_skip (Optional)Allows for commits that have been labeled with [ci skip] or [skip ci] previously to be discovered by the resource.
commit_verification_keys (Optional)Array of GPG public keys that the resource will check against to verify the commit (details below).
commit_verification_key_ids (Optional) - Array of GPG public key ids that the resource will check against to - verify the commit (details below). The corresponding keys will be - fetched from the key server specified in gpg_keyserver. The - ids can be short id, long id or fingerprint. -
gpg_keyserver (Optional)GPG keyserver to download the public keys from. Defaults to hkp://keyserver.ubuntu.com/.
git_crypt_key (Optional) - Base64 encoded git-crypt - key. Setting this will unlock / decrypt the repository with - git-crypt. To get the key simply execute git-crypt - export-key -- - | base64 in an encrypted repository. -
https_tunnel (Optional)Information about an HTTPS proxy that will be used to tunnel SSH-based git commands over. Has the following sub-properties: -
    -
  • proxy_host: Required. The host name or IP of the proxy server
  • -
  • proxy_port: Required. The proxy server's listening port
  • -
  • proxy_user: Optional. If the proxy requires authentication, use this username
  • -
  • proxy_password: Optional. If the proxy requires authenticate, use this password
  • -
-
debug (Optional) - Set to true to enable. Sets the following for check/get/put - steps of the resource. Secrets may not be correctly redacted due the - JSON encoding of longer secret strings. -
-set -x
-export GIT_TRACE=1
-export GIT_TRACE_PACKFILE=1
-export GIT_CURL_VERBOSE=1
-        
-
- -The following fields are used exclusively by `version_type: commits`. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field NameDescription
branch (Optional) - The branch to track. This is optional if the resource is only used in - get steps; however, it is required when used in a - put step. If unset, get steps will checkout - the repository's default branch; usually master but could - be different. -
paths (Optional) - If specified (as a list of glob patterns), only changes to the specified files will yield new versions from check. - Example: -
-- name: repo
-  type: git
-  source:
-    paths:
-      - some-folder/*
-      - another/folder/path/*
-        
-
sparse_paths (Optional) - If specified (as a list of glob patterns), only these paths will be - checked out. Should be used with paths to only trigger on - desired paths. paths and sparse_paths may be - the same or you can configure sparse_paths to check out - other paths. - Example: -
-- name: repo
-  type: git
-  source:
-    paths:
-      - some-folder/*
-      - another/folder/path/*
-    sparse_paths:
-      - some-folder/*
-      - another/folder/path/*
-        
-
ignore_paths (Optional) - The inverse of paths; changes to the specified files are - ignored.

Note that if you want to push commits that change these - files via a put, the commit will still be "detected", as check - and put both introduce versions. To avoid this you - should define a second resource that you use for commits that change - files that you don't want to feed back into your pipeline - think of one - as read-only (with ignore_paths) and one as write-only - (which shouldn't need it).

- Example: -
-- name: repo
-  type: git
-  source:
-    ignore_paths:
-      - some-folder/*
-      - another/folder/path/*
-        
-
tag_filter (Optional) - If specified, the resource will only detect commits that have a tag - matching the expression that have been made against the - branch. Patterns are glob(7) - compatible (as in, bash compatible). -
tag_regex (Optional) - If specified, the resource will only detect commits that have a tag - matching the expression that have been made against the - branch. Patterns are grep - compatible (extended matching enabled, matches entire lines only). - Ignored if tag_filter is also specified. -
tag_behaviour (Optional) - If match_tagged (the default), then the resource will only - detect commits that are tagged with a tag matching - tag_regex and tag_filter, and match all other - filters. If match_tag_ancestors, then the resource will - only detect commits matching all other filters and that are ancestors of - a commit that are tagged with a tag matching tag_regex and - tag_filter. -
fetch_tags (Optional)If true the flag --tags will be used to fetch all tags in the repository. If false no tags will be fetched.
commit_filter (Optional)Object containing commit message filters -
    -
  • exclude: Optional. Array containing strings that should cause a commit to be skipped
  • -
  • exclude_all_match: Optional. Boolean wheater it should match all the exclude filters "AND", default: false
  • -
  • include: Optional. Array containing strings that MUST be included in commit messages for the commit to not be skipped
  • -
  • include_all_match: Optional. Boolean wheater it should match all the include filters "AND", default: false
  • -
-

Note: You must escape any regex sensitive characters, since the string is used as a regex filter. For example, using [skip deploy] or [deploy skip] to skip non-deployment related commits in a deployment pipeline:

-
-commit_filter:
-  exclude: ["\\[skip deploy\\]", "\\[deploy skip\\]"]
-      
-
version_depth (Optional)The number of versions to return when performing a check
search_remote_refs (Optional) - True to search remote refs for the input version when checking out - during the get step. This can be useful during the get step - after a put step for unconventional workflows. One example - workflow is the refs/for/<branch> workflow used by - gerrit which 'magically' creates a refs/changes/nnn - reference instead of the straight forward - refs/for/<branch> reference that a git remote would - usually create. See also out params.refs_prefix. -
- -The following fields are used exclusively by `version_type: tags`. - - - - - - - - - - - - - - - - - -
Field NameDescription
tag_filters (Optional) - A list of glob patterns used to filter tags. Only matching tags will be - returned. Patterns are glob(7) - compatible (as in, bash compatible). If you're only specifying one glob - pattern you can use tag_filter. -
tag_regex (Optional) - Regex pattern used to filter tags. Only matching tags will be returned. - Patterns are grep - compatible (extended matching enabled). - Ignored if tag_filter(s) is also specified. - Examples: -
    -
  • ^v[0-9]+\.[0-9]+\.[0-9]+$ - Matches tags like v1.2.3 and won't match tags that include metadata or labels
  • -
  • ^v2\.[0-9]+\.[0-9]+$ - Matches tags starting with v2
  • -
      -
tag_sort (Optional) Sorting is applied after filtering. Accepts the following values: -
    -
  • creatordate (Default): Uses git's built-in sorting by the creation date of the tag
  • -
  • version: Uses sort -V to sort all matching tags.
  • -
-
- -The following fields are used exclusively by `version_type: branches`. - - - - - - - - - - - - - -
Field NameDescription
branch_filters (Optional) - A list of glob patterns used to filter branches. Only matching branches will be returned. - Patterns are glob(7) - compatible (as in, bash compatible). -
branch_regex (Optional) - Regex pattern used to filter branches. Only matching branches will be returned. - Patterns are grep - compatible (extended matching enabled). - Ignored if branch_filters is also specified. -
- -### Example - -Resource configuration for a private repo with an HTTPS proxy: - -``` yaml -resources: -- name: source-code - type: git - source: - uri: git@github.com:concourse/git-resource.git - branch: master - private_key: | - -----BEGIN RSA PRIVATE KEY----- - ... - -----END RSA PRIVATE KEY----- - git_config: - - name: core.bigFileThreshold - value: 10m - disable_ci_skip: true - git_crypt_key: AEdJVEN...snip...AAA== - https_tunnel: - proxy_host: proxy-server.mycorp.com - proxy_port: 3128 - proxy_user: myuser - proxy_password: myverysecurepassword -``` - -Resource configuration for a private repo with a private submodule from different git server: - -``` yaml -resources: -- name: source-code - type: git - source: - uri: git@github.com:concourse/git-resource.git - branch: master - submodule_credentials: - - host: some.other.git.server - username: user - password: verysecurepassword - private_key: | - -----BEGIN RSA PRIVATE KEY----- - ... - -----END RSA PRIVATE KEY----- -``` - -Fetching a repo with only 100 commits of history: - -``` yaml -- get: source-code - params: {depth: 100} -``` - -Pushing local commits to the repo: - -``` yaml -- get: some-other-repo -- put: source-code - params: {repository: some-other-repo} -``` - -Fetching a repo pinned to a specific commit: - -``` yaml -resources: -- name: source-code - type: git - source: - uri: git@github.com:concourse/git-resource.git - branch: master - version: - ref: commit-sha -``` - -Resource configuration for a repo authenticated by a GitHub App: - -``` yaml -resources: -- name: source-code - type: git - source: - uri: https://github.com/concourse/git-resource - branch: master - github_app_id: mPL4Ecjs4FqYC9PKcGny - github_app_org: concourse - github_app_private_key: | - -----BEGIN RSA PRIVATE KEY----- - ... - -----END RSA PRIVATE KEY----- -``` - -## Behavior - -The behavior of the resource changes based on the specified `version_type`. -Expand the relevant section to learn more about how the `check/get/put` steps -work for each `version_type`. - -
- version_type: commits - -### `check`: Check for new commits - -The repository is cloned (or pulled if already present), and any commits -from the given version on are returned. If no version is given, the ref -for `HEAD` is returned. - -Any commits that contain the string `[ci skip]` will be ignored. This -allows you to commit to your repository without triggering a new version. - -### `get`: Clone the repository, at the given ref - -Clones the repository to the destination, and locks it down to a given ref. -It will return the same given ref as version. - -`git-crypt` encrypted repositories will automatically be decrypted, when the -correct key is provided set in `source.git_crypt_key`. - -#### `get` Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field NameDescription
depth
Optional
- If a positive integer is given, shallow clone the repository - using the --depth option. To prevent newer commits that do - not pass a paths filter test from skewing the cloned - history away from version.ref, this resource will - automatically deepen the clone until version.ref is found - again. It will deepen with exponentially increasing steps until a - maximum of 127 + depth commits or else resort to unshallow - the repository. -
fetch
Optional
- Additional branches to fetch and make available in the cloned repository. - This is useful when you need to perform operations like rebasing or - merging with branches other than the one being checked out. -

- Specify as a list of branch names. Each branch will be fetched from - origin and made available as a local branch. -

- Example: Fetching additional branches for rebasing -
-- get: source-code
-  params:
-    fetch:
-      - develop
-      - main
-      - feature/experimental
-        
- After the get step completes, you can perform operations - like: -
-- task: rebase-on-main
-  config:
-    platform: linux
-    inputs:
-      - name: source-code
-    run:
-      path: sh
-      args:
-        - -exc
-        - |
-          cd source-code
-          git rebase main
-        
-
fetch_tags
Optional
- If true the flag --tags will be used to fetch all tags in the repository. If false no tags will be fetched. -

- Will override fetch_tags source configuration if defined. -
submodules
Optional
- If none, submodules will not be fetched. If specified as a - list of paths, only the given paths will be fetched. If not specified, - or if all is explicitly specified, all submodules are - fetched. -
submodule_recursive
Optional
If false, a flat submodules checkout is performed. If not specified, or if true is explicitly specified, a recursive checkout is performed.
submodule_remote
Optional
- If true, the submodules are checked out for the specified - remote branch specified in the .gitmodules file of the - repository. If not specified, or if false is explicitly - specified, the tracked sub-module revision of the repository is used to - check out the submodules. -
disable_git_lfs
Optional
If true, will not fetch Git LFS files.
clean_tags
Optional
- If true all incoming tags will be deleted. This is useful - if you want to push tags, but have reasonable doubts that the tags - cached with the resource are outdated. The default value is - false. -
short_ref_format
Optional
When populating .git/short_ref use this printf format. Defaults to %s.
timestamp_format
Optional
- When populating .git/commit_timestamp use this options to - pass to git - log --date. Defaults to iso8601. -
describe_ref_options
Optional
- When populating .git/describe_ref use this options to call - git - describe. Defaults to --always --dirty --broken. -
all_branches
Optional
- If true the flag --single-branch will be - excluded and all branches will be fetched from the repository. If - false or not specified, only a single branch (either - source.branch or the default branch) will be fetched. -
debug (Optional) - Set to true to enable. Sets the following for check/get/put - steps of the resource. Secrets may not be correctly redacted due the - JSON encoding of longer secret strings. -
-set -x
-export GIT_TRACE=1
-export GIT_TRACE_PACKFILE=1
-export GIT_CURL_VERBOSE=1
-        
-
- -#### GPG signature verification - -If `commit_verification_keys` or `commit_verification_key_ids` is specified in -the source configuration, it will additionally verify that the resulting commit -has been GPG signed by one of the specified keys. It will error if this is not -the case. - -#### Additional files populated - -* `.git/ref`: Version reference detected and checked out. It will usually contain the commit SHA-1 ref, but also the - detected tag name when using `tag_filter` or `tag_regex`. - -* `.git/commit`: Full SHA-1 commit hash. - -* `.git/short_ref`: Short (first seven characters) of the `.git/ref`. Can be templated with `short_ref_format` - parameter. - -* `.git/branch`: Name of the original branch that was cloned. - -* `.git/tags`: Comma-separated list of tags associated with this commit. - -* `.git/author`: Commit author name. - -* `.git/author_date`: Timestamp when the author originally created the commit. - -* `.git/committer`: For committer notification on failed builds. This special file `.git/committer` which is populated - with the email address of the author of the last commit. This can be used - together with a resource to send notifications in an `on_failure` step. - -* `.git/committer_name`: Name of the commit author. - -* `.git/committer_date`: Timestamp when the commit was added to the repository. - -* `.git/commit_message`: For publishing the Git commit message on successful builds. - -* `.git/commit_timestamp`: For tagging builds with a timestamp. - -* `.git/describe_ref`: Version reference detected and checked out. Can be templated with `describe_ref_options` - parameter. By default, it will contain the - `--g` (eg. `v1.6.2-1-g13dfd7b`). If the repo - was never tagged before, this falls back to a short commit SHA-1 ref. - -* `.git/url`: Web URL to view the commit (if applicable). - -* `.git/metadata.json`: Complete metadata object in JSON format containing all metadata fields. - -### `put`: Push to a repository - -Push the checked-out reference to the source's URI and branch. All tags are -also pushed to the source. If a fast-forward for the branch is not possible -and the `rebase` parameter is not provided, the push will fail. - -#### Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field NameDescription
repository
Required
The path of the repository to push to the source.
rebase
Optional
If pushing fails with non-fast-forward, continuously attempt rebasing and pushing.
rebase_strategy
Optional
Merge strategy to use during rebase (e.g., recursive, ort, octopus, ours, subtree). Passed via --strategy flag.
rebase_strategy_option
Optional
Strategy-specific options passed via -X flag. Can be a string (space-separated) or array of options (e.g., theirs, ours, ignore-space-change).
merge
Optional
If pushing fails with non-fast-forward, continuously attempt to merge remote to local before pushing. Only one of merge or rebase can be provided, but not both.
returning
Optional
- When passing the merge flag, specify whether the merge - commit or the original, unmerged commit should be passed as the output - ref. Options are merged and unmerged. Defaults - to merged. -
tag
Optional
If this is set then HEAD will be tagged. The value should be a path to a file containing the name of the tag.
only_tag
Optional
When set to 'true' push only the tags of a repo.
tag_prefix
Optional
If specified, the tag read from the file will be prepended with this string. This is useful for adding v in front of version numbers.
force
Optional
When set to 'true' this will force the branch to be pushed regardless of the upstream state.
annotate
Optional
- If specified the tag will be an annotated - tag rather than a lightweight - tag. The value should be a path to a file containing the annotation - message. -
notes
Optional
If this is set then notes will be added to HEAD to the refs/notes/commits ref. The value should be a path to a file containing the notes.
branch
Optional
- The branch to push commits. -

- Note that the version produced by the put step will be picked - up by subsequent get steps even if the branch - differs from the branch specified in the source. To avoid - this, you should use two resources of read-only and write-only. -
refs_prefix
Optional
- Allows pushing to refs other than heads. Defaults to refs/heads. -

- Useful when paired with source.search_remote_refs in cases where the git remote renames the ref you pushed. -
push_options (Optional) - An array of strings that will be passed as --push-option - flags when pushing to the repository. Example: -
-- push-option-1
-- push-option-2
-        
-
debug (Optional) - Set to true to enable. Sets the following for check/get/put - steps of the resource. Secrets may not be correctly redacted due the - JSON encoding of longer secret strings. -
-set -x
-export GIT_TRACE=1
-export GIT_TRACE_PACKFILE=1
-export GIT_CURL_VERBOSE=1
-        
-
- -
- -
- version_type: tags - -### `check`: Check for new tags - -Checks for new tags, filtering by `tag_filters` or `tag_regex` if specified. -Each version emitted will be the tag and the ref it points to. - -### `get`: Clone the repository at the given tag - -Shallow clones the repository to the destination, checking out the given -tag in a detached HEAD state. - -`git-crypt` encrypted repositories will automatically be decrypted, when the -correct key is provided set in `source.git_crypt_key`. - -#### `get` Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field NameDescription
submodules
Optional
- If none, submodules will not be fetched. If specified as a - list of paths, only the given paths will be fetched. If not specified, - or if all is explicitly specified, all submodules are - fetched. -
submodule_recursive
Optional
If false, a flat submodules checkout is performed. If not specified, or if true is explicitly specified, a recursive checkout is performed.
submodule_remote
Optional
- If true, the submodules are checked out for the specified - remote branch specified in the .gitmodules file of the - repository. If not specified, or if false is explicitly - specified, the tracked sub-module revision of the repository is used to - check out the submodules. -
disable_git_lfs
Optional
If true, will not fetch Git LFS files.
short_ref_format
Optional
When populating .git/short_ref use this printf format. Defaults to %s.
timestamp_format
Optional
- When populating .git/commit_timestamp use this options to - pass to git - log --date. Defaults to iso8601. -
debug (Optional) - Set to true to enable. Sets the following for check/get/put - steps of the resource. Secrets may not be correctly redacted due the - JSON encoding of longer secret strings. -
-set -x
-export GIT_TRACE=1
-export GIT_TRACE_PACKFILE=1
-export GIT_CURL_VERBOSE=1
-        
-
- -#### GPG signature verification - -If `commit_verification_keys` or `commit_verification_key_ids` is specified in -the source configuration, it will additionally verify that the resulting commit -has been GPG signed by one of the specified keys. It will error if this is not -the case. - -#### Additional files populated - -* `.git/tag`: Tag detected and checked out. - -* `.git/ref`: Full SHA-1 commit hash. - -* `.git/short_ref`: Short (first seven characters) of the `.git/ref`. Can be templated with `short_ref_format` - parameter. - -* `.git/author`: Commit author name. - -* `.git/author_date`: Timestamp when the author originally created the commit. - -* `.git/committer`: For committer notification on failed builds. This special file `.git/committer` which is populated - with the email address of the author of the last commit. This can be used - together with a resource to send notifications in an `on_failure` step. - -* `.git/committer_name`: Name of the commit author. - -* `.git/committer_date`: Timestamp when the commit was added to the repository. - -* `.git/commit_message`: For publishing the Git commit message on successful builds. - -* `.git/commit_timestamp`: For tagging builds with a timestamp. - -* `.git/url`: Web URL to view the commit (if applicable). - -* `.git/metadata.json`: Complete metadata object in JSON format containing all metadata fields. - -### `put`: No-op - -There is no implementation for this step. It will error if you try to use it. If -you want to push new tags, use `version_type: commits`. - -
- -
- version_type: branches - -### `check`: Check for new branches - -The list of remote branches are enumerated, filtered by `branch_filters` or -`branch_regex` if specified, and compared to the existing set of branches. If -any branches are new or removed, a new version is emitted. Branches are sorted -lexicographically using `sort` before comparing. - -If no branches are found a special `NONE` version is emitted. - -### `get`: List the given branches - -Produces a `branches.json` file containing a JSON array of the branches from the -given version. Example of the contents of the file: -```json -[ - "feature/add-button", - "feature/refactor-model", - "fix/ui-bug" -] -``` - -### `put`: No-op - -There is no implementation for this step. It will error if you try to use it. - -
- -## Development - -### Prerequisites - -* golang is *required* - version 1.9.x is tested; earlier versions may also - work. -* docker is *required* - version 17.06.x is tested; earlier versions may also - work. - -### Running the tests - -The tests have been embedded with the `Dockerfile`; ensuring that the testing -environment is consistent across any `docker` enabled platform. When the docker -image builds, the test are run inside the docker container, on failure they -will stop the build. - -Run the tests with the following command: - -```sh -docker build -t git-resource --target tests . -``` - -#### Note about the integration tests - -If you want to run the integration tests, a bit more work is required. You will require -an actual git repo to which you can push and pull, configured for SSH access. To do this, -add two files to `integration-tests/ssh` (note that names **are** important): - -* `test_key`: This is the private key used to authenticate against your repo. -* `test_repo`: This file contains one line of the form `test_repo_url[#test_branch]`. - If the branch is not specified, it defaults to `master`. For example, - `git@github.com:concourse-git-tester/git-resource-integration-tests.git` or - `git@github.com:concourse-git-tester/git-resource-integration-tests.git#testing` - -### Contributing - -Please make all pull requests to the `master` branch and ensure tests pass -locally. diff --git a/assets/askpass.sh b/assets/askpass.sh deleted file mode 100755 index 517ed39e..00000000 --- a/assets/askpass.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -if [ -z "$GIT_SSH_PRIVATE_KEY_PASS" ]; then - echo "Private key has a passphrase but private_key_passphrase has not been set." >&2 - exit 1 -fi -echo "$GIT_SSH_PRIVATE_KEY_PASS" diff --git a/assets/check b/assets/check deleted file mode 100755 index 7c4a96cb..00000000 --- a/assets/check +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -set -e - -exec 3>&1 # make stdout available as fd 3 for the result -exec 1>&2 # redirect all output to stderr for logging - -assets="$(dirname $0)" -source "${assets}/common.sh" - -payload="$(cat <&0)" - -unknown_keys=$(jq --slurpfile schema "${assets}/source_schema.json" '(.source // [] | keys_unsorted) - ($schema[0] | keys_unsorted)' <<< "$payload") - -if jq --exit-status 'length > 0' <<< "$unknown_keys" &>/dev/null; then - echo "Found unknown keys in source:" - jq '.[]' <<< "$unknown_keys" - exit 1 -fi - -debug=$(jq -r '.source.debug // false' <<< "$payload") -if [[ "$debug" == "true" ]]; then - echo "debug mode enabled" - set -x - export GIT_TRACE=1 - export GIT_TRACE_PACKFILE=1 - export GIT_CURL_VERBOSE=1 -fi - -git_config_payload=$(jq -r '.source.git_config // []' <<< "$payload") -configure_git_global "${git_config_payload}" -load_pubkey "$payload" -configure_https_tunnel "$payload" -configure_git_ssl_verification "$payload" -setup_github_app_credentials "$payload" -configure_credentials "$payload" - -# These vars are used by multiple version_type's -destination=$TMPDIR/git-resource-repo-cache -uri=$(jq -r '.source.uri // ""' <<< "$payload") -uri=${uri# } -if [[ -z "$uri" ]]; then - echo "source.uri is required and must not be empty" - exit 1 -fi - -version_type=$(jq -r '.source.version_type // "commits"' <<< "$payload") - -case "$version_type" in - commits) - source "${assets}/check_commits.sh" - ;; - tags) - source "${assets}/check_tags.sh" - ;; - branches) - source "${assets}/check_branches.sh" - ;; - *) - echo "unknown version_type: $version_type" - exit 1 - ;; -esac diff --git a/assets/check_branches.sh b/assets/check_branches.sh deleted file mode 100755 index 5b5c3f8c..00000000 --- a/assets/check_branches.sh +++ /dev/null @@ -1,53 +0,0 @@ -branch_filters=$(jq '.source.branch_filters // []' <<< "$payload") -branch_regex=$(jq -r '.source.branch_regex // ""' <<< "$payload") -prev_branches=$(jq -r '.version.branches // ""' <<< "$payload") - -if [[ $(jq 'length' <<< "$branch_filters") -ge 1 && -n "$branch_regex" ]]; then - echo "only one of branch_filters or branch_regex can be specified" - exit 1 -fi - -all_branches=$(git ls-remote --heads "$uri" | awk '{sub("refs/heads/", "", $2); print $2}') - -filtered_branches="" -filtered=false -if [[ $(jq 'length' <<< "$branch_filters") -ge 1 ]]; then - filtered=true - while IFS= read -r branch; do - while IFS= read -r filter; do - if [[ "$branch" == $filter ]]; then - filtered_branches+="${branch}"$'\n' - break - fi - done <<< "$(jq -r '.[]' <<< "$branch_filters")" - done <<< "$all_branches" -fi - -if [[ -n "$branch_regex" ]]; then - filtered=true - filtered_branches=$(echo "$all_branches" | grep -E "$branch_regex" -) -fi - -if [[ "$filtered" == "false" ]]; then - filtered_branches=$all_branches -fi - -sorted_branches=$(echo "$filtered_branches" | sort | paste -sd ',' -) -sorted_branches=${sorted_branches#,} -sorted_branches=${sorted_branches%,} - -if [[ -z "$sorted_branches" ]]; then - echo "No matching branches found. Setting empty version." - sorted_branches="NONE" -fi - -if [[ "$sorted_branches" == "$prev_branches" ]]; then - echo "No change from previous version" - echo "[]" >&3 - exit 0 -fi - -jq -n \ - --arg branches "$sorted_branches" \ - --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S)" \ - '[{branches: $branches, timestamp: $timestamp}]' >&3 diff --git a/assets/check_commits.sh b/assets/check_commits.sh deleted file mode 100755 index 9ecbd681..00000000 --- a/assets/check_commits.sh +++ /dev/null @@ -1,292 +0,0 @@ -branch=$(jq -r '.source.branch // ""' <<< "$payload") -branch=${branch# } -paths="$(jq -r '(.source.paths // ["."])[]' <<< "$payload")" # those "'s are important -ignore_paths="$(jq -r '":!" + (.source.ignore_paths // [])[]' <<< "$payload")" # these ones too -tag_filter=$(jq -r '.source.tag_filter // ""' <<< "$payload") -tag_filter=${tag_filter# } -tag_regex=$(jq -r '.source.tag_regex // ""' <<< "$payload") -tag_regex=${tag_regex# } -tag_behaviour=$(jq -r '.source.tag_behaviour // "match_tagged"' <<< "$payload") -ref=$(jq -r '.version.ref // ""' <<< "$payload") -skip_ci_disabled=$(jq -r '.source.disable_ci_skip // false' <<< "$payload") -filter_include=$(jq '.source.commit_filter.include // []' <<< "$payload") -filter_include_all_match=$(jq -r '.source.commit_filter.include_all_match // false' <<< "$payload") -filter_exclude=$(jq '.source.commit_filter.exclude // []' <<< "$payload") -filter_exclude_all_match=$(jq -r '.source.commit_filter.exclude_all_match // false' <<< "$payload") -version_depth=$(jq -r '.source.version_depth // 1' <<< "$payload") -reverse=false - -# Optimization when last commit only is checked and skip ci is disabled -# Get the commit id with git ls-remote instead of downloading the whole repo -if [ "$skip_ci_disabled" = "true" ] && \ - [ "$version_depth" = "1" ] && \ - [ "$paths" = "." ] && \ - [ -z "$ignore_paths" ] && \ - [ -z "$tag_filter" ] && \ - [ -z "$tag_regex" ] && \ - jq -e 'length == 0' <<<"$filter_include" &>/dev/null && \ - jq -e 'length == 0' <<<"$filter_exclude" &>/dev/null -then - branchflag="HEAD" - if [ -n "$branch" ]; then - branchflag="$branch" - fi - commit=$(git ls-remote $uri $branchflag | awk 'NR<=1{print $1}') - if [ -z "$commit" ]; then - echo "No commit returned. Invalid branch?" - exit 1 - fi - if [ -z "$ref" ] || [ "$ref" = "$commit" ]; then - echo $commit | jq -R '.' | jq -s "map({ref: .})" >&3 - exit 0 - fi -fi - -tagflag="" -if [ -n "$tag_filter" ] && [ -n "$tag_regex" ] ; then - echo "Cannot provide both tag_filter and tag_regex" - exit 1 -elif [ -n "$tag_filter" ] || [ -n "$tag_regex" ] ; then - tagflag="--tags" -else - tagflag="--no-tags" -fi - -if [ "$tag_behaviour" != "match_tagged" ] && [ "$tag_behaviour" != "match_tag_ancestors" ]; then - echo "Invalid tag_behaviour. Must be one of 'match_tagged' or 'match_tag_ancestors'." - exit 1 -fi - -for filter in "$filter_include" "$filter_exclude" -do - if jq -e 'type != "array"' <<<"$filter" &>/dev/null - then - echo 'invalid commit filter (expected array of strings)' - echo "$filter" - exit 1 - fi -done - -if [ "$version_depth" -le 0 ]; then - echo "Invalid version_depth. Must be > 0." - exit 1 -fi - -# We're just checking for commits; we don't ever need to fetch LFS files here! -export GIT_LFS_SKIP_SMUDGE=1 - -if [ -d $destination ]; then - cd $destination - if [ "$tagflag" = "--tags" ]; then - git fetch origin 'refs/heads/*:refs/heads/*' --tags -f - else - git fetch origin $tagflag $branch -f - git reset --soft FETCH_HEAD - fi -else - branchflag="" - if [ -n "$branch" ]; then - branchflag="--branch $branch" - fi - - # Determine optimal filter based on whether path filtering is used - if [ "$paths" = "." ] && [ -z "$ignore_paths" ]; then - # No path filtering - use most aggressive filter for maximum performance - filter_flag="--filter=tree:0" - else - # Path filtering needed - keep trees to analyze paths, skip blobs - filter_flag="--filter=blob:none" - fi - - if [ "$tagflag" = "--tags" ]; then - # For tag filtering, don't use --single-branch - tags may be on any branch - git clone --bare $filter_flag --progress $uri $destination --tags - else - git clone --bare $filter_flag --single-branch --progress $uri $branchflag $destination $tagflag - fi - cd $destination - # bare clones don't configure the refspec - if [ -n "$branch" ]; then - git remote set-branches --add origin $branch - fi -fi - -if [ -n "$ref" ] && git cat-file -e "$ref"; then - reverse=true - log_range="${ref}~1..HEAD" - - # if ${ref} does not have parents, ${ref}~1 raises the error: "unknown revision or path not in the working tree" - # the initial commit in a branch will never have parents, but rarely, subsequent commits can also be parentless - orphan_commits=$(git rev-list --max-parents=0 HEAD) - for orphan_commit in ${orphan_commits}; do - if [ "${ref}" = "${orphan_commit}" ]; then - log_range="HEAD" - break - fi - done -else - log_range="" - ref="" -fi - -if [ "$paths" = "." ] && [ -z "$ignore_paths" ]; then - paths_search="" -else - paths_search=`echo "-- $paths $ignore_paths" | tr "\n\r" " "` -fi - -list_command="git rev-list --all --first-parent $log_range $paths_search" -if jq -e 'length > 0' <<<"$filter_include" &>/dev/null -then - list_command+=" | git rev-list --stdin --date-order --first-parent --no-walk=unsorted " - include_items=$(echo $filter_include | jq -r -c '.[]') - for wli in "$include_items" - do - list_command+=" --grep=\"$wli\"" - done - if [ "$filter_include_all_match" == "true" ]; then - list_command+=" --all-match" - fi -fi - -if jq -e 'length > 0' <<<"$filter_exclude" &>/dev/null -then - list_command+=" | git rev-list --stdin --date-order --invert-grep --first-parent --no-walk=unsorted " - exclude_items=$(echo $filter_exclude | jq -r -c '.[]') - for bli in "$exclude_items" - do - list_command+=" --grep=\"$bli\"" - done - if [ "$filter_exclude_all_match" == "true" ]; then - list_command+=" --all-match" - fi -fi - - -if [ "$skip_ci_disabled" != "true" ]; then - list_command+=" | git rev-list --stdin --date-order --grep=\"\\[ci\\sskip\\]\" --grep=\"\\[skip\\sci\\]\" --invert-grep --first-parent --no-walk=unsorted" -fi - -replace_escape_chars() { - sed -e 's/[]\/$*.^[]/\\&/g' <<< $1 -} - -lines_including_and_after() { - local escaped_string=$(replace_escape_chars $1) - sed -ne "/$escaped_string/,$ p" -} - -#if no range is selected just grab the last commit that fits the filter -if [ -z "$log_range" ] && [ -z "$tag_filter" ] && [ -z "$tag_regex" ] -then - list_command+="| git rev-list --stdin --date-order --no-walk=unsorted -$version_depth --reverse" -fi - -if [ "$reverse" == "true" ] && [ -z "$tag_filter" ] && [ -z "$tag_regex" ] -then - list_command+="| git rev-list --stdin --date-order --first-parent --no-walk=unsorted --reverse" -fi - -get_tags_matching_filter() { - local list_command=$1 - local tags=$2 - for tag in $tags; do - # We turn the tag ref (e.g. v1.0.0) into the object name - # (e.g. 1a410efbd13591db07496601ebc7a059dd55cfe9) and use grep to check it is in the output - # of list_command - if it isn't, it doesn't pass one of the other filters and shouldn't be - # outputted. - local commit=$(git rev-list -n 1 $tag) - local this_list_command="$list_command | grep -cFx \"$commit\"" - local list_output="$(set -f; eval "$this_list_command"; set +f)" - if [ "$list_output" -ge 1 ]; then - jq -cn '{ref: $tag, commit: $commit}' --arg tag $tag --arg commit $commit - fi - done -} - -get_tags_match_ancestors_filter() { - local list_command=$1 - local tags=$2 - - # Sort commits so that we look at the oldest commits first - local this_list_command="$list_command | git rev-list --stdin --date-order --first-parent --no-walk=unsorted --reverse" - local list_output="$(set -f; eval "$this_list_command"; set +f)" - - # Store all the tag names in an associative array for quick lookups. - # Also gather the commits each tag is attached to so we can quickly match - # candidate commits in a best-case scenario. - declare -A eligible_tag_names=() - declare -A eligible_tag_commits=() - local tag tag_commit - for tag in $tags; do - eligible_tag_names["$tag"]=1 - tag_commit=$(git rev-list -n 1 "$tag" 2>/dev/null || true) - if [ -n "$tag_commit" ]; then - eligible_tag_commits["$tag_commit"]=1 - fi - done - - # Check each commit and only output commits that are ancestors of tags. - for commit in $list_output; do - local is_ancestor=false - - # Fast path: check if the commit itself is the target of an eligible tag - if [ -n "${eligible_tag_commits[$commit]+x}" ]; then - is_ancestor=true - else - # Find all the tags whose history contains this commit - then check if - # any are eligible tags - local containing_tag - while IFS= read -r containing_tag; do - [ -z "$containing_tag" ] && continue - if [ -n "${eligible_tag_names[$containing_tag]+x}" ]; then - is_ancestor=true - break - fi - done < <(git tag --contains "$commit") - fi - - if [ "$is_ancestor" = true ]; then - jq -cn '{ref: $commit}' --arg commit $commit - fi - done -} - -if [ -n "$tag_filter" ] || [ -n "$tag_regex" ]; then - # Create a suffix to "git tag" that will apply the tag filter - if [ -n "$tag_filter" ]; then - tag_filter_cmd="--list \"$tag_filter\"" - elif [ -n "$tag_regex" ]; then - tag_filter_cmd="| grep -Ex \"$tag_regex\"" - fi - - # Build a list of tag refs (e.g. v1.0.0) that match the filter - if [ -n "$ref" ] && [ -n "$branch" ]; then - tags=$(set -f; eval "git tag --sort=creatordate --contains $ref --merged $branch $tag_filter_cmd"; set +f) - elif [ -n "$ref" ]; then - tags=$(set -f; eval "git tag --sort=creatordate $tag_filter_cmd | lines_including_and_after $ref"; set +f) - else - branch_flag= - if [ -n "$branch" ]; then - branch_flag="--merged $branch" - fi - tags=$(set -f; eval "git tag --sort=creatordate $branch_flag $tag_filter_cmd"; set +f) - fi - - # Only proceed if we actually found any tags - if [ -n "$tags" ]; then - if [ "$tag_behaviour" == "match_tagged" ]; then - get_tags_matching_filter "$list_command" "$tags" | tail "-$version_depth" | jq -s "map(.)" >&3 - else - get_tags_match_ancestors_filter "$list_command" "$tags" | tail "-$version_depth" | jq -s "map(.)" >&3 - fi - else - jq -n "[]" >&3 - fi -else - { - set -f - eval "$list_command" - set +f - } | jq -R '.' | jq -s "map({ref: .})" >&3 -fi diff --git a/assets/check_tags.sh b/assets/check_tags.sh deleted file mode 100755 index 680768e0..00000000 --- a/assets/check_tags.sh +++ /dev/null @@ -1,85 +0,0 @@ -tag_filters=$(jq '(.source.tag_filters // []) + (if .source.tag_filter then [.source.tag_filter] else [] end)' <<< "$payload") -tag_regex=$(jq -r '.source.tag_regex // ""' <<< "$payload") -tag_sort=$(jq -r '.source.tag_sort // "creatordate"' <<< "$payload") -prev_tag=$(jq -r '.version.tag // ""' <<< "$payload") - -if [[ $(jq 'length' <<< "$tag_filters") -ge 1 && -n "$tag_regex" ]]; then - echo "only one of tag_filters or tag_regex can be specified" - exit 1 -fi - -if [[ ! -d "$destination" ]]; then - git init --bare --quiet "$destination" -fi - -cd "$destination" - -# git fetch exits 1 when the refspec matches no refs, so short-circuit -# when the remote has no tags. -if [[ -z "$(git ls-remote --tags "$uri")" ]]; then - echo '[]' >&3 - exit 0 -fi - -git fetch --depth=1 \ - --filter=tree:0 \ - --no-tags \ - "$uri" \ - '+refs/tags/*:refs/tags/*' - -# get all tags, sorting by creation-date -# --format results in tab-separated values. First column is the tag, second is -# the commit sha the tag points to. If it's an annotated tag, the third column -# will dereference the tag to the actual commit sha it points to; otherwise the -# third column will be empty. -all_tags=$(git for-each-ref \ - --sort=creatordate \ - --format='%(refname:short)%09%(objectname)%09%(*objectname)' \ - refs/tags/) - -filtered_tags="" -filtered=false -if [[ $(jq 'length' <<< "$tag_filters") -ge 1 ]]; then - filtered=true - while IFS= read -r tag; do - while IFS= read -r filter; do - # $tag is the tag name and refs joined by tabs. We only want to - # match against the tag name, so strip everything from the first - # tab onward. - if [[ "${tag%%$'\t'*}" == $filter ]]; then - filtered_tags+="${tag}"$'\n' - break - fi - done <<< "$(jq -r '.[]' <<< "$tag_filters")" - done <<< "$all_tags" -fi - -if [[ -n "$tag_regex" ]]; then - filtered=true - while IFS= read -r tag; do - if echo "${tag%%$'\t'*}" | grep -E "$tag_regex" >/dev/null; then - filtered_tags+="${tag}"$'\n' - fi - done <<< "$all_tags" -fi - -if [[ "$filtered" == "false" ]]; then - filtered_tags=$all_tags -fi - -sorted_tags="" -sorted=false -if [[ "$tag_sort" == "version" ]]; then - sorted=true - sorted_tags=$(echo "$filtered_tags" | sort -V) -fi - -if [[ "$sorted" == "false" ]]; then - sorted_tags=$filtered_tags -fi - -jtags=$(printf '%s' "$sorted_tags" | jq -Rn \ - --arg prevtag "$prev_tag" \ - '[inputs | (./"\t") | map(select(. != "")) | {tag: .[0], ref: (.[2] // .[1])}] | .[(map(.tag) | index($prevtag)):] | map(select((.tag // "") != "" and (.ref // "") != ""))') - -echo "$jtags" >&3 diff --git a/assets/common.sh b/assets/common.sh deleted file mode 100644 index 48eed757..00000000 --- a/assets/common.sh +++ /dev/null @@ -1,433 +0,0 @@ -export TMPDIR=${TMPDIR:-/tmp} -export GIT_CRYPT_KEY_PATH=~/git-crypt.key - -load_pubkey() { - local private_key_path=$TMPDIR/git-resource-private-key - local private_key_user=$(jq -r '.source.private_key_user // empty' <<< "$1") - local forward_agent=$(jq -r '.source.forward_agent // false' <<< "$1") - local passphrase="$(jq -r '.source.private_key_passphrase // empty' <<< "$1")" - local uri=$(jq -r '.source.uri // ""' <<< "$1") - - (jq -r '.source.private_key // empty' <<< "$1") > $private_key_path - - if [ -s $private_key_path ]; then - chmod 0600 $private_key_path - - # create or re-initialize ssh-agent - init_ssh_agent - - SSH_ASKPASS_REQUIRE=force SSH_ASKPASS=$(dirname $0)/askpass.sh GIT_SSH_PRIVATE_KEY_PASS="$passphrase" DISPLAY= ssh-add $private_key_path > /dev/null - - mkdir -p ~/.ssh - cat > ~/.ssh/config <> ~/.ssh/config <> ~/.ssh/config <> ~/.ssh/config < /dev/null - exit_code=$? - set -e - - if [[ ${exit_code} -eq 2 ]]; then - # ssh-agent does not exist, create ssh-agent - eval $(ssh-agent) > /dev/null 2>&1 - trap "kill $SSH_AGENT_PID" EXIT - else - # ssh-agent exist, remove all identities - ssh-add -D &> /dev/null - fi - -} - -configure_https_tunnel() { - tunnel=$(jq -r '.source.https_tunnel // empty' <<< "$1") - - if [ ! -z "$tunnel" ]; then - host=$(echo "$tunnel" | jq -r '.proxy_host // empty') - port=$(echo "$tunnel" | jq -r '.proxy_port // empty') - user=$(echo "$tunnel" | jq -r '.proxy_user // empty') - password=$(echo "$tunnel" | jq -r '.proxy_password // empty') - - pass_file="" - if [ ! -z "$user" ]; then - cat > ~/.ssh/tunnel_config <> ~/.ssh/config - fi - fi -} - -configure_git_global() { - git config --global gc.autoDetach false - local git_config_payload="$1" - eval $(echo "$git_config_payload" | \ - jq -r ".[] | \"git config --global '\\(.name)' '\\(.value)'; \"") -} - -configure_git_local() { - local git_config_payload="$1" - if [ -n "$git_config_payload" ] && [ "$git_config_payload" != "[]" ]; then - echo "$git_config_payload" | jq -r '.[] | [.name, .value] | @tsv' | \ - while IFS=$'\t' read -r name value; do - git config "$name" "$value" - done - fi -} - -configure_git_ssl_verification() { - skip_ssl_verification=$(jq -r '.source.skip_ssl_verification // false' <<< "$1") - if [ "$skip_ssl_verification" = "true" ]; then - export GIT_SSL_NO_VERIFY=true - fi -} - -add_git_metadata_basic() { - local commit=$(git rev-parse HEAD) - local author=$(git log -1 --format=format:%an) - local author_date=$(git log -1 --format=format:%ai) - - jq --arg commit "$commit" \ - --arg author "$author" \ - --arg author_date "$author_date" \ - '. + [ - {name: "commit", value: $commit}, - {name: "author", value: $author}, - {name: "author_date", value: $author_date, type: "time"} - ]' -} - -add_git_metadata_committer() { - local author=$(git log -1 --format=format:%an) - local author_date=$(git log -1 --format=format:%ai) - local committer=$(git log -1 --format=format:%cn) - local committer_date=$(git log -1 --format=format:%ci) - - if [ "$author" = "$committer" ] && [ "$author_date" = "$committer_date" ]; then - jq --arg committer "$committer" --arg committer_date "$committer_date" '. + [ - {name: "committer", value: $committer}, - {name: "committer_date", value: $committer_date, type: "time"} - ]' - else - cat - fi -} - -add_git_metadata_branch() { - local branch=$(git show-ref --heads | \ - sed -n "s/^$(git rev-parse HEAD) refs\/heads\/\(.*\)/\1/p" | \ - jq -R ". | select(. != \"\")" | jq -r -s "map(.) | join (\",\")") - - if [ -n "${branch}" ]; then - jq --arg branch "$branch" '. + [ - {name: "branch", value: $branch} - ]' - else - cat - fi -} - -add_git_metadata_tags() { - local tags=$(git tag --points-at HEAD | \ - jq -R ". | select(. != \"\")" | \ - jq -r -s "map(.) | join(\",\")") - - if [ -n "${tags}" ]; then - jq --arg tags "$tags" '. + [ - {name: "tags", value: $tags} - ]' - else - cat - fi -} - -add_git_metadata_tag() { - local tag=$(git tag --points-at HEAD) - - if [ -n "${tag}" ]; then - jq --arg tag "$tag" '. + [ - {name: "tag", value: $tag} - ]' - else - cat - fi -} - -add_git_metadata_message() { - local message=$(git log -1 --format=format:%B | head -c 10240) - - jq --arg message "$message" '. + [ - {name: "message", value: $message, type: "message"} - ]' -} - -add_git_metadata_url() { - local commit=$(git rev-parse HEAD) - local origin=$(git remote get-url --all origin) 2> /dev/null - - # This is not exhaustive for remote URL formats, but does cover the - # most common hosting scenarios for where a commit URL exists - if [[ ! $origin =~ ^(https?://|ssh://git@|git@)([^/]+)/(.*)$ ]]; then - jq ". + []" - else - local host=${BASH_REMATCH[2]} - local repo_path=${BASH_REMATCH[3]%.git} - - # Remap scp-style names so that "github.com:concourse" + "git-resource" - # becomes "github.com" + "concourse/git-resource" - if [[ ${BASH_REMATCH[1]} == "git@" && $host == *:* ]]; then - repo_path="${host#*:}/${repo_path}" - host=${host%%:*} - fi - - local url="" - case $host in - *github* | *gogs* ) - url="https://${host}/${repo_path}/commit/${commit}" ;; - *gitlab* ) - url="https://${host}/${repo_path}/-/commit/${commit}" ;; - *bitbucket* ) - url="https://${host}/${repo_path}/commits/${commit}";; - esac - - if [ -n "$url" ]; then - jq --arg url "$url" '. + [ - {name: "url", value: $url} - ]' - else - jq ". + []" - fi - fi -} - -git_metadata() { - jq -n "[]" | \ - add_git_metadata_basic | \ - add_git_metadata_committer | \ - add_git_metadata_branch | \ - add_git_metadata_tags | \ - add_git_metadata_message | \ - add_git_metadata_url -} - -git_tag_metadata() { - jq -n "[]" | \ - add_git_metadata_basic | \ - add_git_metadata_committer | \ - add_git_metadata_tag | \ - add_git_metadata_message | \ - add_git_metadata_url -} - -configure_submodule_credentials() { - local username - local password - if [[ "$(jq -r '.source.submodule_credentials // ""' <<< "$1")" == "" ]]; then - return - fi - - for k in $(jq -r '.source.submodule_credentials | keys | .[]' <<< "$1"); do - host=$(jq -r --argjson k "$k" '.source.submodule_credentials[$k].host // ""' <<< "$1") - username=$(jq -r --argjson k "$k" '.source.submodule_credentials[$k].username // ""' <<< "$1") - password=$(jq -r --argjson k "$k" '.source.submodule_credentials[$k].password // ""' <<< "$1") - if [ "$username" != "" -a "$password" != "" -a "$host" != "" ]; then - echo "machine $host login $username password $password" >> "${HOME}/.netrc" - fi - done -} - -configure_credentials() { - local username=$(jq -r '.source.username // ""' <<< "$1") - local password=$(jq -r '.source.password // ""' <<< "$1") - - rm -f $HOME/.netrc - configure_submodule_credentials "$1" - - if [ "$username" != "" -a "$password" != "" ]; then - local credential_hosts=$(jq -r '(.source.credential_hosts // []) | if type == "array" then .[] else . end' <<< "$1") - if [ "$credential_hosts" != "" ]; then - for host in $credential_hosts; do - echo "machine $host login $username password $password" >> "${HOME}/.netrc" - done - else - echo "default login $username password $password" >> "${HOME}/.netrc" - fi - fi -} - -load_git_crypt_key() { - local git_crypt_tmp_key_path=$TMPDIR/git-resource-git-crypt-key - - (jq -r '.source.git_crypt_key // empty' <<< "$1") > $git_crypt_tmp_key_path - - if [ -s $git_crypt_tmp_key_path ]; then - cat $git_crypt_tmp_key_path | tr ' ' '\n' | base64 -d > $GIT_CRYPT_KEY_PATH - fi -} - -create_github_app_jwt() { - # reference: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app - local client_id=$1 - local pem=$2 - local iat=$3 - local exp=$4 - - b64enc() { base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n'; } - - local header_json='{"typ":"JWT","alg":"RS256"}' - - local header=$(echo -n "${header_json}" | b64enc) - - local payload_json="{\"iat\":${iat},\"exp\":${exp},\"iss\":\"${client_id}\"}" - - local payload=$(echo -n "${payload_json}" | b64enc) - - local header_payload="${header}.${payload}" - local signature - signature=$(set -o pipefail; openssl dgst -sha256 -sign <(echo -n "${pem}") \ - <(echo -n "${header_payload}") | b64enc) || { - echo "error: openssl signing failed" >&2 - return 1 - } - - echo "${header_payload}.${signature}" -} - -get_github_app_install_id() { - # references: - # https://docs.github.com/en/rest/apps/apps?apiVersion=2026-03-10#get-an-organization-installation-for-the-authenticated-app - # https://docs.github.com/en/rest/apps/apps?apiVersion=2026-03-10#get-a-repository-installation-for-the-authenticated-app - # https://docs.github.com/en/rest/apps/apps?apiVersion=2026-03-10#get-a-user-installation-for-the-authenticated-app - local base_api_url=$1 - local jwt=$2 - local org=$3 - local user=$4 - local repo=$5 - local install_url="" - - if [ -n "$user" ] && [ -z "$repo" ]; then - install_url="${base_api_url}/users/${user}/installation" - elif [ -n "$org" ]; then - install_url="${base_api_url}/orgs/${org}/installation" - elif [ -n "$user" ] && [ -n "$repo" ]; then - install_url="${base_api_url}/repos/${user}/${repo}/installation" - else - # this should be guarded by the calling function - return 1 - fi - - local install_id_resp=$(curl --max-time 30 --retry 3 -s -X GET -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2026-03-10" -H "Authorization: Bearer ${jwt}" "$install_url") - local install_id=$(jq -r '.id // empty' <<< "$install_id_resp") - - if [ -z "$install_id" ]; then - echo "error: $install_id_resp" >&2 - return 1 - fi - - echo $install_id -} - -get_github_app_access_token() { - # reference: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app?apiVersion=2026-03-10&versionId=free-pro-team%40latest&category=apps&subcategory=oauth-applications&productId=apps&restPage=creating-github-apps%2Cauthenticating-with-a-github-app%2Cgenerating-a-user-access-token-for-a-github-app - local base_api_url=$1 - local jwt=$2 - local install_id=$3 - - local access_token_resp=$(curl --max-time 30 --retry 3 -s -X POST -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2026-03-10" -H "Authorization: Bearer ${jwt}" "${base_api_url}/app/installations/${install_id}/access_tokens") - local access_token=$(jq -r '.token // empty' <<< "$access_token_resp") - - if [ -z "$access_token" ]; then - echo "error: $access_token_resp" >&2 - return 1 - fi - - echo "$access_token" -} - -setup_github_app_credentials() { - local uri=$(jq -r '.source.uri // empty' <<< "$1") - local app_id=$(jq -r '.source.github_app_id // empty' <<< "$1") - local private_key=$(jq -r '.source.github_app_private_key // empty' <<< "$1") - local org=$(jq -r '.source.github_app_org // empty' <<< "$1") - local user=$(jq -r '.source.github_app_user // empty' <<< "$1") - local repo=$(jq -r '.source.github_app_repo // empty' <<< "$1") - - if [[ ! ( -n "${uri}" && -n "${app_id}" && -n "${private_key}" && ( -n "${org}" || -n "${user}" )) ]]; then - return - fi - - if [[ ! $uri =~ ^(https://)([^/]+)/.*$ ]]; then - echo "github app authentication needs an https:// source.uri" - return 1 - fi - - local host=${BASH_REMATCH[2]} - local base_api_url="https://api.${host}" - - local now=$(date +%s) - local iat=$((${now} - 60)) # Issues 60 seconds in the past - local exp=$((${now} + 600)) # Expires 10 minutes in the future - - local jwt - jwt=$(create_github_app_jwt "$app_id" "$private_key" "$iat" "$exp") - if [[ -z "$jwt" ]]; then - echo "failed to create github app jwt" - return 1 - fi - - local install_id - install_id=$(get_github_app_install_id "$base_api_url" "$jwt" "$org" "$user" "$repo") - if [[ -z "$install_id" ]]; then - echo "failed to get github app installation id" - return 1 - fi - - local access_token - access_token=$(get_github_app_access_token "$base_api_url" "$jwt" "$install_id") - if [[ -z "$access_token" ]]; then - echo "failed to get github app access token" - return 1 - fi - - git config --global "credential.https://${host}.helper" "!f() { echo \"username=x-access-token\"; echo \"password=${access_token}\"; }; f" -} diff --git a/assets/deepen_shallow_clone_until_ref_is_found_then_check_out b/assets/deepen_shallow_clone_until_ref_is_found_then_check_out deleted file mode 100755 index c4990185..00000000 --- a/assets/deepen_shallow_clone_until_ref_is_found_then_check_out +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# vim: set ft=sh - -set -e - -readonly max_depth=127 - -declare depth="$1" -readonly ref="$2" -readonly tagflag="$3" - -declare total_depth="$depth" -declare depth_from_ref=$((depth - 1)) - -# A shallow clone may not contain the Git commit $ref: -# 1. The depth of the shallow clone is measured backwards from the latest -# commit on the given head (master or branch), and in the meantime there may -# have been more than $depth commits pushed on top of our $ref. -# 2. If there's a path filter (`paths`/`ignore_paths`), then there may be more -# than $depth such commits pushed to the head (master or branch) on top of -# $ref that are not affecting the filtered paths. -# -# In either case we try to deepen the shallow clone until we find $ref, reach -# the max depth of the repo, or give up after a given depth and resort to deep -# clone. - -git_dir="$(git rev-parse --git-dir)" -readonly git_dir - -while ! git checkout -f -q "$ref~$depth_from_ref" &>/dev/null; do - # once the depth of a shallow clone reaches the max depth of the origin - # repo, Git silenty turns it into a deep clone - if [ ! -e "$git_dir"/shallow ]; then - echo "Reached max depth of the origin repo while deepening the shallow clone, it's a deep clone now" - break - fi - - echo "Could not find ref ${ref}~${depth_from_ref} in a shallow clone of depth ${total_depth}" - - (( depth *= 2 )) - - if [ "$total_depth" -ge "$max_depth" ]; then - echo "Reached depth threshold ${max_depth}, falling back to deep clone..." - git fetch --unshallow origin $tagflag - - break - fi - - echo "Deepening the shallow clone by an additional ${depth}..." - git fetch --deepen "$depth" origin $tagflag - (( total_depth += depth )) -done - -git checkout -f -q "$ref" diff --git a/assets/in b/assets/in deleted file mode 100755 index c501d421..00000000 --- a/assets/in +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash - -set -e - -exec 3>&1 # make stdout available as fd 3 for the result -exec 1>&2 # redirect all output to stderr for logging - -assets="$(dirname $0)" -source "${assets}/common.sh" - -destination=$1 - -if [ -z "$destination" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -payload="$(cat <&0)" - -unknown_keys=$(jq --slurpfile schema "${assets}/in_schema.json" '(.params // [] | keys_unsorted) - ($schema[0] | keys_unsorted)' <<< "$payload") - -if jq --exit-status 'length > 0' <<< "$unknown_keys" &>/dev/null; then - echo "Found unknown keys in get params:" - jq '.[]' <<< "$unknown_keys" - exit 1 -fi - -src_debug=$(jq -r '.source.debug // false' <<< "$payload") -params_debug=$(jq -r '.params.debug // false' <<< "$payload") -if [[ "$src_debug" == "true" || "$params_debug" == "true" ]]; then - echo "debug mode enabled" - set -x - export GIT_TRACE=1 - export GIT_TRACE_PACKFILE=1 - export GIT_CURL_VERBOSE=1 -fi - -git_config_payload=$(jq -r '.source.git_config // []' <<< "$payload") -configure_git_global "${git_config_payload}" -load_pubkey "$payload" -load_git_crypt_key "$payload" -configure_https_tunnel "$payload" -configure_git_ssl_verification "$payload" -setup_github_app_credentials "$payload" -configure_credentials "$payload" - -# These vars are used by multiple version_type's -uri=$(jq -r '.source.uri // ""' <<< "$payload") -uri=${uri# } -if [[ -z "$uri" ]]; then - echo "source.uri is required and must not be empty" - exit 1 -fi - -version_type=$(jq -r '.source.version_type // "commits"' <<< "$payload") - -case "$version_type" in - commits) - source "${assets}/in_commits.sh" - ;; - tags) - source "${assets}/in_tags.sh" - ;; - branches) - source "${assets}/in_branches.sh" - ;; - *) - echo "unknown version_type: $version_type" - exit 1 - ;; -esac diff --git a/assets/in_branches.sh b/assets/in_branches.sh deleted file mode 100755 index 890a387a..00000000 --- a/assets/in_branches.sh +++ /dev/null @@ -1,20 +0,0 @@ -branches=$(jq -r '.version.branches // ""' <<< "$payload") - -if [[ "$branches" == "NONE" ]]; then - echo "[]" > "${destination}/branches.json" - jq -n \ - --argjson version "$(jq -r '.version' <<< "$payload")" \ - --arg branches_value "NONE" \ - '{version: $version, metadata: [{name: "branches", value: $branches_value}]}' >&3 - exit 0 -fi - -echo "$branches" | jq -Rc 'split(",")' > "${destination}/branches.json" - -# Format branches as a multi-line string for nicely printing in metadata -branches_metadata=$(echo "$branches" | jq -Rrc 'split(",") | join("\n")') - -jq -n \ - --argjson version "$(jq -r '.version' <<< "$payload")" \ - --arg branches_value "$branches_metadata" \ - '{version: $version, metadata: [{name: "branches", value: $branches_value}]}' >&3 diff --git a/assets/in_commits.sh b/assets/in_commits.sh deleted file mode 100755 index 1f3d28f1..00000000 --- a/assets/in_commits.sh +++ /dev/null @@ -1,264 +0,0 @@ -branch=$(jq -r '.source.branch // ""' <<< "$payload") -sparse_paths="$(jq -r '(.source.sparse_paths // ["."])[]' <<< "$payload")" # those "'s are important -ref=$(jq -r '.version.ref // "HEAD"' <<< "$payload") -override_branch=$(jq -r '.version.branch // ""' <<< "$payload") -depth=$(jq -r '(.params.depth // 0)' <<< "$payload") -fetch=$(jq -r '(.params.fetch // [])[]' <<< "$payload") -submodules=$(jq -r '(.params.submodules // "all")' <<< "$payload") -submodule_recursive=$(jq -r '(.params.submodule_recursive // true)' <<< "$payload") -submodule_remote=$(jq -r '(.params.submodule_remote // false)' <<< "$payload") -commit_verification_key_ids=$(jq -r '(.source.commit_verification_key_ids // [])[]' <<< "$payload") -commit_verification_keys=$(jq -r '(.source.commit_verification_keys // [])[]' <<< "$payload") -tag_filter=$(jq -r '.source.tag_filter // ""' <<< "$payload") -tag_regex=$(jq -r '.source.tag_regex // ""' <<< "$payload") -fetch_tags=$(jq -r '.params.fetch_tags' <<< "$payload") -gpg_keyserver=$(jq -r '.source.gpg_keyserver // "hkp://keyserver.ubuntu.com/"' <<< "$payload") -disable_git_lfs=$(jq -r '(.params.disable_git_lfs // false)' <<< "$payload") -clean_tags=$(jq -r '(.params.clean_tags // false)' <<< "$payload") -short_ref_format=$(jq -r '(.params.short_ref_format // "%s")' <<< "$payload") -timestamp_format=$(jq -r '(.params.timestamp_format // "iso8601")' <<< "$payload") -describe_ref_options=$(jq -r '(.params.describe_ref_options // "--always --dirty --broken")' <<< "$payload") -search_remote_refs_flag=$(jq -r '(.source.search_remote_refs // false)' <<< "$payload") -all_branches=$(jq -r '(.params.all_branches // false)' <<< "$payload") - -# If params not defined, get it from source -if [ -z "$fetch_tags" ] || [ "$fetch_tags" == "null" ] ; then - fetch_tags=$(jq -r '.source.fetch_tags' <<< "$payload") -fi - -branchflag="" -if [ -n "$branch" ]; then - branchflag="--branch $branch" -fi - -if [ -n "$override_branch" ]; then - echo "Override $branch with $override_branch" - branchflag="--branch $override_branch" -fi - -depthflag="" -if test "$depth" -gt 0 2> /dev/null; then - depthflag="--depth $depth" -fi - -tagflag="" -if [ "$fetch_tags" == "false" ] ; then - tagflag="--no-tags" -elif [ -n "$tag_filter" ] || [ -n "$tag_regex" ] || [ "$fetch_tags" == "true" ] ; then - tagflag="--tags" -fi - -nocheckoutflag="" -if [ "$sparse_paths" != "." ] && [ "$sparse_paths" != "" ]; then - nocheckoutflag=" --no-checkout" -fi - -if [ "$disable_git_lfs" == "true" ]; then - # skip the fetching of LFS objects for all following git commands - export GIT_LFS_SKIP_SMUDGE=1 -fi - -singlebranchflag="--single-branch" -if [ "${all_branches,,}" == "true" ]; then - singlebranchflag="" -fi - -git clone --progress $singlebranchflag $depthflag $uri $branchflag $destination $tagflag $nocheckoutflag - -cd $destination - -configure_git_local "${git_config_payload}" - -if [ "$sparse_paths" != "." ] && [ "$sparse_paths" != "" ]; then - git config core.sparseCheckout true - echo "$sparse_paths" >> ./.git/info/sparse-checkout -fi - -git fetch origin refs/notes/*:refs/notes/* $tagflag - -if [ "$depth" -gt 0 ]; then - "${assets}/deepen_shallow_clone_until_ref_is_found_then_check_out" "$depth" "$ref" "$tagflag" -else - if [ "$search_remote_refs_flag" == "true" ] && ! [ -z "$branchflag" ] && ! git rev-list -1 $ref 2> /dev/null > /dev/null; then - change_ref=$(git ls-remote origin | grep $ref | cut -f2) - if ! [ -z "$change_ref" ]; then - echo "$ref not found locally, but search_remote_refs is enabled. Attempting to fetch $change_ref first." - git fetch origin $change_ref - else - echo "WARNING: couldn't find a ref for $ref listed on the remote" - fi - fi - git checkout -f -q "$ref" -fi - -invalid_key() { - echo "Invalid GPG key in: ${commit_verification_keys}" - exit 2 -} - -commit_not_signed() { - commit_id=$(git rev-parse ${ref}) - echo "The commit ${commit_id} is not signed" - exit 1 -} - -if [ ! -z "${commit_verification_keys}" ] || [ ! -z "${commit_verification_key_ids}" ] ; then - if [ ! -z "${commit_verification_keys}" ]; then - echo "${commit_verification_keys}" | gpg --batch --import || invalid_key "${commit_verification_keys}" - fi - if [ ! -z "${commit_verification_key_ids}" ]; then - echo "${commit_verification_key_ids}" | \ - xargs --no-run-if-empty -n1 gpg --batch --keyserver $gpg_keyserver --recv-keys - fi - git verify-commit $(git rev-list -n 1 $ref) || commit_not_signed -fi - -git log -1 --oneline -git clean --force --force -d -git submodule sync - -if [ -f $GIT_CRYPT_KEY_PATH ]; then - echo "unlocking git repo" - git-crypt unlock $GIT_CRYPT_KEY_PATH -fi - - -submodule_parameters="" -if [ "$submodule_remote" != "false" ]; then - submodule_parameters+=" --remote " -fi -if [ "$submodule_recursive" != "false" ]; then - submodule_parameters+=" --recursive " -fi - -if [ "$submodules" != "none" ]; then - value_regexp="." - if [ "$submodules" != "all" ]; then - value_regexp="$(echo $submodules | jq -r 'map(. + "$") | join("|")')" - fi - - { - git config --file .gitmodules --name-only --get-regexp '\.path$' "$value_regexp" | - sed -e 's/^submodule\.\(.\+\)\.path$/\1/' - } | while read submodule_name; do - submodule_path="$(git config --file .gitmodules --get "submodule.${submodule_name}.path")" - submodule_url="$(git config --file .gitmodules --get "submodule.${submodule_name}.url")" - - if [ "$depth" -gt 0 ]; then - git config "submodule.${submodule_name}.update" "!${assets}/deepen_shallow_clone_until_ref_is_found_then_check_out $depth" - fi - - if ! [ -e "$submodule_path" ]; then - echo $'\e[31m'"warning: skipping missing submodule: $submodule_path"$'\e[0m' - continue - fi - - # check for ssh submodule_credentials - submodule_cred=$(jq --arg submodule_url "${submodule_url}" '.source.submodule_credentials // [] | [.[] | select(.url==$submodule_url)] | first // empty' <<< ${payload}) - - if [[ -z ${submodule_cred} ]]; then - - # update normally - git submodule update --init --no-fetch $depthflag $submodule_parameters "$submodule_path" - - else - - # create or re-initialize ssh-agent - init_ssh_agent - - private_key=$(jq -r '.private_key' <<< ${submodule_cred}) - passphrase=$(jq -r '.private_key_passphrase // empty' <<< ${submodule_cred}) - - private_key_path=$(mktemp -t git-resource-submodule-private-key.XXXXXX) - echo "${private_key}" > ${private_key_path} - chmod 0600 ${private_key_path} - - # add submodule private_key identity - SSH_ASKPASS_REQUIRE=force SSH_ASKPASS=$(dirname $0)/askpass.sh GIT_SSH_PRIVATE_KEY_PASS="$passphrase" DISPLAY= ssh-add $private_key_path > /dev/null - - git submodule update --init --no-fetch $depthflag $submodule_parameters "$submodule_path" - - # restore main ssh-agent (if needed) - load_pubkey "${payload}" - - fi - - if [ "$depth" -gt 0 ]; then - git config --unset "submodule.${submodule_name}.update" - fi - done -fi - -for branch in $fetch; do - git fetch origin $branch - if ! git show-ref --verify --quiet refs/heads/$branch; then - git branch $branch FETCH_HEAD - fi -done - -if [ "$ref" == "HEAD" ]; then - return_ref=$(git rev-parse HEAD) -else - return_ref=$ref -fi - -# Store committer email in .git/committer. Can be used to send email to last committer on failed build -# Using https://github.com/mdomke/concourse-email-resource for example -git --no-pager log -1 --pretty=format:"%ae" > .git/committer - -git --no-pager log -1 --pretty=format:"%an" > .git/committer_name - -# Store git-resource returned version ref .git/ref. Useful to know concourse -# pulled ref in following tasks and resources. -echo "${return_ref}" > .git/ref - -metadata=$(git_metadata) -echo "${metadata}" | jq '.' > .git/metadata.json - -# Store short ref with templating. Useful to build Docker images with -# a custom tag -echo "${return_ref}" | cut -c1-7 | awk "{ printf \"${short_ref_format}\", \$1 }" > .git/short_ref - -# Write individual metadata fields to separate files - -# .git/commit - full SHA hash -echo "${metadata}" | jq -r '.[] | select(.name == "commit") | .value' > .git/commit -# .git/author - commit author name -echo "${metadata}" | jq -r '.[] | select(.name == "author") | .value' > .git/author -# .git/author_date - timestamp when the author originally created the commit -echo "${metadata}" | jq -r '.[] | select(.name == "author_date") | .value' > .git/author_date - -# .git/tags - branch name(s) containing this commit (comma-separated if multiple) -echo "${metadata}" | jq -r '.[] | select(.name == "branch") | .value // ""' > .git/branch -# .git/tags - comma-separated list of tags -echo "${metadata}" | jq -r '.[] | select(.name == "tags") | .value // ""' > .git/tags -# .git/url - web URL to view commit (if applicable) -echo "${metadata}" | jq -r '.[] | select(.name == "url") | .value // ""' > .git/url -# .git/committer_date - timestamp when the commit was created in the repository -echo "${metadata}" | jq -r '.[] | select(.name == "committer_date") | .value // ""' > .git/committer_date - -# Store commit message in .git/commit_message. Can be used to inform about -# the content of a successful build. -# Using https://github.com/cloudfoundry-community/slack-notification-resource -# for example -git log -1 --format=format:%B > .git/commit_message - -# Store commit date in .git/commit_timestamp. Can be used for tagging builds -git log -1 --format=%cd --date=${timestamp_format} > .git/commit_timestamp - -# Store describe_ref when available. Useful to build Docker images with -# a custom tag, or package to publish -echo "$(git describe ${describe_ref_options})" > .git/describe_ref - - -if [ "$clean_tags" == "true" ]; then - git tag | xargs git tag -d -fi - -jq -n \ - --arg ref "$return_ref" \ - --argjson metadata "$metadata" \ - '{ - version: {ref: $ref}, - metadata: $metadata -}' >&3 diff --git a/assets/in_schema.json b/assets/in_schema.json deleted file mode 100644 index 0eacd84c..00000000 --- a/assets/in_schema.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "depth": "", - "fetch": "", - "fetch_tags": "", - "submodules": "", - "submodule_recursive": "", - "submodule_remote": "", - "disable_git_lfs": "", - "clean_tags": "", - "short_ref_format": "", - "timestamp_format": "", - "describe_ref_options": "", - "all_branches": "", - "debug": "" -} diff --git a/assets/in_tags.sh b/assets/in_tags.sh deleted file mode 100755 index b1fb2a8e..00000000 --- a/assets/in_tags.sh +++ /dev/null @@ -1,168 +0,0 @@ -tag=$(jq -r '.version.tag // ""' <<< "$payload") -ref=$(jq -r '.version.ref // ""' <<< "$payload") -submodules=$(jq -r '(.params.submodules // "all")' <<< "$payload") -submodule_recursive=$(jq -r '(.params.submodule_recursive // true)' <<< "$payload") -submodule_remote=$(jq -r '(.params.submodule_remote // false)' <<< "$payload") -disable_git_lfs=$(jq -r '(.params.disable_git_lfs // false)' <<< "$payload") -commit_verification_key_ids=$(jq -r '(.source.commit_verification_key_ids // [])[]' <<< "$payload") -commit_verification_keys=$(jq -r '(.source.commit_verification_keys // [])[]' <<< "$payload") -gpg_keyserver=$(jq -r '.source.gpg_keyserver // "hkp://keyserver.ubuntu.com/"' <<< "$payload") -short_ref_format=$(jq -r '(.params.short_ref_format // "%s")' <<< "$payload") -timestamp_format=$(jq -r '(.params.timestamp_format // "iso8601")' <<< "$payload") - -if [ "$disable_git_lfs" == "true" ]; then - # skip the fetching of LFS objects for all following git commands - export GIT_LFS_SKIP_SMUDGE=1 -fi - -git config --global advice.detachedHead false -git clone --progress --depth 1 --branch "$tag" "$uri" "$destination" - -cd $destination - -configure_git_local "${git_config_payload}" - -invalid_key() { - echo "Invalid GPG key in: ${commit_verification_keys}" - exit 2 -} - -commit_not_signed() { - commit_id=$(git rev-parse ${ref}) - echo "The commit ${commit_id} is not signed" - exit 1 -} - -if [ ! -z "${commit_verification_keys}" ] || [ ! -z "${commit_verification_key_ids}" ] ; then - if [ ! -z "${commit_verification_keys}" ]; then - echo "${commit_verification_keys}" | gpg --batch --import || invalid_key "${commit_verification_keys}" - fi - if [ ! -z "${commit_verification_key_ids}" ]; then - echo "${commit_verification_key_ids}" | \ - xargs --no-run-if-empty -n1 gpg --batch --keyserver $gpg_keyserver --recv-keys - fi - git verify-commit $(git rev-list -n 1 $ref) || commit_not_signed -fi - -git log -1 --oneline -git clean --force --force -d -git submodule sync - -if [ -f $GIT_CRYPT_KEY_PATH ]; then - echo "unlocking git repo" - git-crypt unlock $GIT_CRYPT_KEY_PATH -fi - -submodule_parameters="" -if [ "$submodule_remote" != "false" ]; then - submodule_parameters+=" --remote " -fi -if [ "$submodule_recursive" != "false" ]; then - submodule_parameters+=" --recursive " -fi - -if [ "$submodules" != "none" ]; then - value_regexp="." - if [ "$submodules" != "all" ]; then - value_regexp="$(echo $submodules | jq -r 'map(. + "$") | join("|")')" - fi - - { - git config --file .gitmodules --name-only --get-regexp '\.path$' "$value_regexp" | - sed -e 's/^submodule\.\(.\+\)\.path$/\1/' - } | while read submodule_name; do - submodule_path="$(git config --file .gitmodules --get "submodule.${submodule_name}.path")" - submodule_url="$(git config --file .gitmodules --get "submodule.${submodule_name}.url")" - - if ! [ -e "$submodule_path" ]; then - echo $'\e[31m'"warning: skipping missing submodule: $submodule_path"$'\e[0m' - continue - fi - - # check for ssh submodule_credentials - submodule_cred=$(jq --arg submodule_url "${submodule_url}" '.source.submodule_credentials // [] | [.[] | select(.url==$submodule_url)] | first // empty' <<< "${payload}") - - if [[ -z ${submodule_cred} ]]; then - - # update normally - git submodule update --init --no-fetch $submodule_parameters "$submodule_path" - - else - - # create or re-initialize ssh-agent - init_ssh_agent - - private_key=$(jq -r '.private_key' <<< ${submodule_cred}) - passphrase=$(jq -r '.private_key_passphrase // empty' <<< ${submodule_cred}) - - private_key_path=$(mktemp -t git-resource-submodule-private-key.XXXXXX) - echo "${private_key}" > ${private_key_path} - chmod 0600 ${private_key_path} - - # add submodule private_key identity - SSH_ASKPASS_REQUIRE=force SSH_ASKPASS=$(dirname $0)/askpass.sh GIT_SSH_PRIVATE_KEY_PASS="$passphrase" DISPLAY= ssh-add $private_key_path > /dev/null - - git submodule update --init --no-fetch $submodule_parameters "$submodule_path" - - # restore main ssh-agent (if needed) - load_pubkey "${payload}" - - fi - - done -fi - -if [ "$ref" == "HEAD" ]; then - return_ref=$(git rev-parse HEAD) -else - return_ref=$ref -fi - -# Store committer email in .git/committer. Can be used to send email to last committer on failed build -# Using https://github.com/mdomke/concourse-email-resource for example -git --no-pager log -1 --pretty=format:"%ae" > .git/committer - -git --no-pager log -1 --pretty=format:"%an" > .git/committer_name - -# Store git-resource returned version ref .git/ref. Useful to know concourse -# pulled ref in following tasks and resources. -echo "${return_ref}" > .git/ref - -metadata=$(git_tag_metadata) -echo "${metadata}" | jq '.' > .git/metadata.json - -# Store short ref with templating. Useful to build Docker images with -# a custom tag -echo "${return_ref}" | cut -c1-7 | awk "{ printf \"${short_ref_format}\", \$1 }" > .git/short_ref - -# Write individual metadata fields to separate files - -# .git/tag - the tag that's been checked out -echo "${metadata}" | jq -r '.[] | select(.name == "tag") | .value' > .git/tag -# .git/author - commit author name -echo "${metadata}" | jq -r '.[] | select(.name == "author") | .value' > .git/author -# .git/author_date - timestamp when the author originally created the commit -echo "${metadata}" | jq -r '.[] | select(.name == "author_date") | .value' > .git/author_date -# .git/url - web URL to view commit (if applicable) -echo "${metadata}" | jq -r '.[] | select(.name == "url") | .value // ""' > .git/url -# .git/committer_date - timestamp when the commit was created in the repository -echo "${metadata}" | jq -r '.[] | select(.name == "committer_date") | .value // ""' > .git/committer_date - -# Store commit message in .git/commit_message. Can be used to inform about -# the content of a successful build. -# Using https://github.com/cloudfoundry-community/slack-notification-resource -# for example -git log -1 --format=format:%B > .git/commit_message - -# Store commit date in .git/commit_timestamp. Can be used for tagging builds -git log -1 --format=%cd --date=${timestamp_format} > .git/commit_timestamp - - -jq -n \ - --arg ref "$return_ref" \ - --arg tag "$tag" \ - --argjson metadata "$metadata" \ - '{ - version: {ref: $ref, tag: $tag}, - metadata: $metadata -}' >&3 diff --git a/assets/out b/assets/out deleted file mode 100755 index 836b731d..00000000 --- a/assets/out +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -set -e - -exec 3>&1 # make stdout available as fd 3 for the result -exec 1>&2 # redirect all output to stderr for logging - -assets="$(dirname $0)" -source "${assets}/common.sh" - -source=$1 - -if [ -z "$source" ]; then - echo "usage: $0 " - exit 1 -fi - -payload="$(cat <&0)" - -unknown_keys=$(jq --slurpfile schema "${assets}/out_schema.json" '(.params // [] | keys_unsorted) - ($schema[0] | keys_unsorted)' <<< "$payload") - -if jq --exit-status 'length > 0' <<< "$unknown_keys" &>/dev/null; then - echo "Found unknown keys in put params:" - jq '.[]' <<< "$unknown_keys" - exit 1 -fi - -src_debug=$(jq -r '.source.debug // false' <<< "$payload") -params_debug=$(jq -r '.params.debug // false' <<< "$payload") -if [[ "$src_debug" == "true" || "$params_debug" == "true" ]]; then - echo "debug mode enabled" - set -x - export GIT_TRACE=1 - export GIT_TRACE_PACKFILE=1 - export GIT_CURL_VERBOSE=1 -fi - -git_config_payload=$(jq -r '.source.git_config // []' <<< "$payload") -configure_git_global "${git_config_payload}" -load_pubkey "$payload" -configure_https_tunnel "$payload" -configure_git_ssl_verification "$payload" -setup_github_app_credentials "$payload" -configure_credentials "$payload" - -# These vars are used by multiple version_type's -uri=$(jq -r '.source.uri // ""' <<< "$payload") -uri=${uri# } -if [[ -z "$uri" ]]; then - echo "source.uri is required and must not be empty" - exit 1 -fi - -version_type=$(jq -r '.source.version_type // "commits"' <<< "$payload") - -case "$version_type" in - commits) - source "${assets}/out_commits.sh" - ;; - tags) - echo "version_type 'tags' does not support the put step. Use version_type 'commits' if you want to push tags." - exit 1 - ;; - branches) - echo "version_type 'branches' does not support the put step" - exit 1 - ;; - *) - echo "unknown version_type: $version_type" - exit 1 - ;; -esac diff --git a/assets/out_commits.sh b/assets/out_commits.sh deleted file mode 100755 index 9b36ef52..00000000 --- a/assets/out_commits.sh +++ /dev/null @@ -1,218 +0,0 @@ -branch=$(jq -r '.source.branch // ""' <<< "$payload") -repository=$(jq -r '.params.repository // ""' <<< "$payload") -tag=$(jq -r '.params.tag // ""' <<< "$payload") -tag_prefix=$(jq -r '.params.tag_prefix // ""' <<< "$payload") -rebase=$(jq -r '.params.rebase // false' <<< "$payload") -rebase_strategy=$(jq -r '.params.rebase_strategy // ""' <<< "$payload") -rebase_strategy_option=$(jq -r '.params.rebase_strategy_option // ""' <<< "$payload") -merge=$(jq -r '.params.merge // false' <<< "$payload") -returning=$(jq -r '.params.returning // "merged"' <<< "$payload") -force=$(jq -r '.params.force // false' <<< "$payload") -only_tag=$(jq -r '.params.only_tag // false' <<< "$payload") -annotation_file=$(jq -r '.params.annotate // ""' <<< "$payload") -notes_file=$(jq -r '.params.notes // ""' <<< "$payload") -override_branch=$(jq -r '.params.branch // ""' <<< "$payload") -push_options=$(jq -r '.params.push_options // []' <<< "$payload") -# useful for pushing to special ref types like refs/for in gerrit. -refs_prefix=$(jq -r '.params.refs_prefix // "refs/heads"' <<< "$payload") - -if [ -z "$branch" ] && [ "$only_tag" != "true" ] && [ -z "$override_branch" ]; then - echo "invalid payload. Must specify one of: source.branch, params.branch, or set params.only_tag=true" - exit 1 -fi - -if [ -z "$repository" ]; then - echo "invalid payload (missing params.repository)" - exit 1 -fi - -if [ "$merge" = "true" ] && [ "$rebase" = "true" ]; then - echo "invalid push strategy (either merge or rebase can be set, but not both)" - exit 1 -fi - -cd $source - -if [ -n "$tag" ] && [ ! -f "$tag" ]; then - echo "tag file '$tag' does not exist" - exit 1 -fi - -if [ -n "$annotation_file" ] && [ ! -f $annotation_file ]; then - echo "annotation file '$annotation_file' does not exist" - exit 1 -fi - -forceflag="" -if [ $force = "true" ]; then - forceflag="--force" -fi - -push_options_flags="" -if [ "$push_options" != "[]" ]; then - push_options_flags=$(echo "$push_options" | jq -r '.[] | "--push-option " + .') -fi - -if [ -n "$override_branch" ]; then - echo "Override $branch with $override_branch" - branch=$override_branch -fi - -tag_name="" -if [ -n "$tag" ]; then - tag_name="$(cat $tag)" -fi - -annotate="" -if [ -n "$annotation_file" ]; then - annotate=" -a -F $source/$annotation_file" -fi - -cd $repository - -tag() { - if [ -n "$tag_name" ]; then - git tag -f "${tag_prefix}${tag_name}" $annotate - fi -} - -push_src_and_tags() { - git push --tags push-target HEAD:$refs_prefix/$branch $forceflag $push_options_flags -} - -push_tags() { - git push --tags push-target $forceflag $push_options_flags -} - -add_and_push_notes() { - if [ -n "$notes_file" ]; then - git notes add -F "../${notes_file}" - git push push-target refs/notes/* $push_options_flags - fi -} - -push_with_result_check() { - # oh god this is really the only way to do this - result_file=$(mktemp $TMPDIR/git-result.XXXXXX) - - echo 0 > $result_file - - { - tag 2>&1 && push_src_and_tags 2>&1 && add_and_push_notes 2>&1 || { - echo $? > $result_file - } - } | tee $TMPDIR/push-failure - - # despite what you may think, the embedded cat does not include the - # trailing linebreak - # - # $() appears to trim it - # - # someone rewrite this please - # - # pull requests welcome - if [ "$(cat $result_file)" = "0" ]; then - echo "pushed" - eval "$1=0" - return - fi - - # failed for reason other than non-fast-forward / fetch-first - if ! grep -q '\[rejected\]\|\[remote rejected\].*cannot lock ref' $TMPDIR/push-failure; then - echo "failed with non-rebase error" - eval "$1=1" - return - fi - - eval "$1=2" -} - -git remote add push-target $uri -commit_to_push=$(git rev-parse HEAD) - -if [ "$only_tag" = "true" ]; then - tag - push_tags -elif [ "$merge" = "true" ]; then - while true; do - echo "merging..." - - git reset --hard $commit_to_push - - git fetch push-target "refs/notes/*:refs/notes/*" - git pull --no-edit push-target $branch - - result="0" - push_with_result_check result - if [ "$result" = "0" ]; then - break - elif [ "$result" = "1" ]; then - exit 1 - fi - - echo "merging and trying again..." - done -elif [ "$rebase" = "true" ]; then - rebase_cmd="git pull --rebase=merges" - - # Add strategy if specified - if [ -n "$rebase_strategy" ]; then - rebase_cmd="$rebase_cmd --strategy=$rebase_strategy" - fi - - # Add strategy options if specified, can be string or array - if [ -n "$rebase_strategy_option" ] && [ "$rebase_strategy_option" != "null" ]; then - # Check if it's an array or string - if echo "$rebase_strategy_option" | jq -e 'type == "array"' > /dev/null 2>&1; then - # It's already an array from jq - strategy_options=$(echo "$rebase_strategy_option" | jq -r '.[] | "-X" + .') - for opt in $strategy_options; do - rebase_cmd="$rebase_cmd $opt" - done - else - # It's a string - could be space-separated options - for opt in $rebase_strategy_option; do - rebase_cmd="$rebase_cmd -X$opt" - done - fi - fi - - while true; do - echo "rebasing using rebase command: $rebase_cmd push-target $branch..." - - git fetch push-target "refs/notes/*:refs/notes/*" - $rebase_cmd push-target $branch - - result="0" - push_with_result_check result - if [ "$result" = "0" ]; then - break - elif [ "$result" = "1" ]; then - exit 1 - fi - - echo "rebasing and trying again..." - done -else - tag - push_src_and_tags - add_and_push_notes -fi - -if [ "$merge" = "true" ] && [ "$returning" = "unmerged" ]; then - version_ref="$(echo "$commit_to_push" | jq -R .)" -else - version_ref="$(git rev-parse HEAD | jq -R .)" -fi - -if [ -n "$override_branch" ]; then - jq -n "{ - version: {branch: $(echo $override_branch | jq -R .), ref: $version_ref}, - metadata: $(git_metadata) - }" >&3 -else - jq -n "{ - version: {ref: $version_ref}, - metadata: $(git_metadata) - }" >&3 -fi diff --git a/assets/out_schema.json b/assets/out_schema.json deleted file mode 100644 index 82070863..00000000 --- a/assets/out_schema.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "repository": "", - "rebase": "", - "rebase_strategy": "", - "rebase_strategy_option": "", - "merge": "", - "returning": "", - "tag": "", - "only_tag": "", - "tag_prefix": "", - "force": "", - "annotate": "", - "notes": "", - "branch": "", - "refs_prefix": "", - "debug": "", - "push_options": "" -} diff --git a/assets/source_schema.json b/assets/source_schema.json deleted file mode 100644 index 5dc564d7..00000000 --- a/assets/source_schema.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version_type": "", - "uri": "", - "branch": "", - "private_key": "", - "private_key_user": "", - "private_key_passphrase": "", - "forward_agent": "", - "username": "", - "password": "", - "credential_hosts": "", - "paths": "", - "sparse_paths": "", - "ignore_paths": "", - "skip_ssl_verification": "", - "tag_filter": "", - "tag_regex": "", - "tag_behaviour": "", - "fetch_tags": "", - "submodule_credentials": "", - "git_config": "", - "disable_ci_skip": "", - "commit_verification_keys": "", - "commit_verification_key_ids": "", - "gpg_keyserver": "", - "git_crypt_key": "", - "https_tunnel": "", - "commit_filter": "", - "version_depth": "", - "search_remote_refs": "", - "debug": "", - "branch_filters": "", - "branch_regex": "", - "tag_filters": "", - "tag_sort": "", - "github_app_id": "", - "github_app_private_key": "", - "github_app_org": "", - "github_app_user": "", - "github_app_repo": "" -} diff --git a/ci/tests.yml b/ci/tests.yml deleted file mode 100644 index 70825723..00000000 --- a/ci/tests.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -platform: linux - -image_resource: - type: docker-image - source: {repository: concourse/git-resource} - -inputs: -- name: git-resource - -run: - path: git-resource/test/all.sh diff --git a/integration-tests/helpers.sh b/integration-tests/helpers.sh deleted file mode 100644 index 86876884..00000000 --- a/integration-tests/helpers.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/bash - -set -e -u -set -o pipefail - -init_integration_tests() { - local test_dir=$1 - - if [[ ! -f "$test_dir/ssh/test_key" || ! -f "$test_dir/ssh/test_repo" ]]; then - echo "$test_dir/ssh/test_key and $test_dir/ssh/test_repo must BOTH exist. Skipping integration tests." 1>&2 - exit 0 - fi - - cp $test_dir/tunnel/squid-noauth.conf /etc/squid/squid.conf - squid - sleep 2 - - export INTG_REPO=$(cat $test_dir/ssh/test_repo | cut -d '#' -f1) - - branch=$(cat $test_dir/ssh/test_repo | cut -d '#' -f2) - [[ "$INTG_REPO" == "$branch" ]] && branch=master - - export INTG_BRANCH=$branch -} - -check_uri_with_private_key_and_incomplete_tunnel_info() { - jq -n "{ - source: { - uri: $(echo $INTG_REPO | jq -R .), - private_key: $(cat $1 | jq -s -R .), - branch: $(echo $INTG_BRANCH | jq -R .), - https_tunnel: {} - } - }" | ${resource_dir}/check "$2" | tee /dev/stderr -} - -check_uri_with_private_key_and_tunnel_info() { - auth=${3:-""} - jq -n "{ - source: { - uri: $(echo $INTG_REPO | jq -R .), - private_key: $(cat $1 | jq -s -R .), - branch: $(echo $INTG_BRANCH | jq -R .), - https_tunnel: { - proxy_host: \"localhost\", - proxy_port: 3128 - $(add_proxy_auth "$auth") - } - } - }" | ${resource_dir}/check "$2" | tee /dev/stderr -} - -get_uri_with_private_key_and_tunnel_info() { - auth=${3:-""} - jq -n "{ - source: { - uri: $(echo $INTG_REPO | jq -R .), - private_key: $(cat $1 | jq -s -R .), - branch: $(echo $INTG_BRANCH | jq -R .), - https_tunnel: { - proxy_host: \"localhost\", - proxy_port: 3128 - $(add_proxy_auth "$auth") - } - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -put_uri_with_private_key_and_tunnel_info() { - auth=${4:-""} - jq -n "{ - source: { - uri: $(echo $INTG_REPO | jq -R .), - private_key: $(cat $1| jq -s -R .), - branch: $(echo $INTG_BRANCH | jq -R .), - https_tunnel: { - proxy_host: \"localhost\", - proxy_port: 3128 - $(add_proxy_auth "$auth") - } - }, - params: { - repository: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -add_proxy_auth() { - local file=$1 - - [[ -f "$file" ]] || exit 0 - - user=$(cat $file | cut -d : -f1) - pass=$(cat $file | cut -d : -f2) - - echo ", proxy_user: \"$user\", proxy_password: \"$pass\"" -} - -test_auth_failure() { - local output=$1 - echo "$output" - - set -e - - ( echo "$output" | grep 'HTTP return code: 407 Proxy Authentication Required' >/dev/null 2>&1 ) - rc=$? - - test "$rc" -eq "0" -} - -run_with_unauthenticated_proxy() { - local basedir=$1 - shift - - cp $basedir/tunnel/squid-noauth.conf /etc/squid/squid.conf - - __run "without" "$@" -} - -run_with_authenticated_proxy() { - local basedir=$1 - shift - - cp $basedir/tunnel/squid-auth.conf /etc/squid/squid.conf - - __run "with" "$@" -} - -__run() { - export TMPDIR=$(mktemp -d ${TMPDIR_ROOT}/git-tests.XXXXXX) - authtype=$1 - shift - - echo -e 'running \e[33m'"$1"$'\e[0m'" $authtype authentication enabled ..." - echo 'Reconfiguring proxy...' - - squid -k reconfigure - - set +e - attempts=10 - while (( attempts )); do - if ss -ltn | grep -q 3128; then - break - else - echo "Waiting for proxy to finish reconfiguring..." - (( attempts-- )) - sleep 1 - fi - done - - if [[ $attempts == 0 ]]; then - echo "Timed out waiting for proxy to reconfigure!" 1>&2 - exit 1 - fi - set -e - - - eval "$@" 2>&1 | sed -e 's/^/ /g' - echo "" -} diff --git a/integration-tests/integration.sh b/integration-tests/integration.sh deleted file mode 100755 index c0718d08..00000000 --- a/integration-tests/integration.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash - -set -e - -basedir="$(dirname "$0")" -. "$basedir/../test/helpers.sh" -. "$basedir/helpers.sh" - -it_can_check_through_a_tunnel() { - output=$(check_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$@" 2>&1) - echo "$output" - - ( echo "$output" | grep 'Via localhost:3128 ->' >/dev/null 2>&1 ) - rc=$? - - test "$rc" -eq "0" -} - -it_can_check_with_empty_tunnel_information() { - output=$(check_uri_with_private_key_and_incomplete_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$@" 2>&1) - echo "$output" - - set +e - ( echo "$output" | grep 'Via localhost:3128 ->' >/dev/null 2>&1 ) - rc=$? - set -e - - test "$rc" -ne "0" -} - -it_can_get_through_a_tunnel() { - get_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$@" -} - -it_can_put_through_a_tunnel() { - get_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$@" - - pushd $TMPDIR - git clone destination staging - date >> staging/test-file - - pushd staging - git add . - git commit -m "Integration Test $(date)" - popd - popd - - put_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination $TMPDIR/staging "$@" -} - -it_can_check_through_a_tunnel_with_auth() { - it_can_check_through_a_tunnel "$basedir/tunnel/auth" -} - -it_can_get_through_a_tunnel_with_auth() { - it_can_get_through_a_tunnel "$basedir/tunnel/auth" -} - -it_can_put_through_a_tunnel_with_auth() { - it_can_put_through_a_tunnel "$basedir/tunnel/auth" -} - -it_cant_check_through_a_tunnel_without_auth() { - set +e - test_auth_failure "$(check_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$@" 2>&1)" -} - -it_cant_get_through_a_tunnel_without_auth() { - set +e - test_auth_failure "$(get_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$@" 2>&1)" -} - -it_cant_put_through_a_tunnel_without_auth() { - get_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination "$basedir/tunnel/auth" - pushd $TMPDIR - git clone destination staging - date >> staging/test-file - - pushd staging - git add . - git commit -m "Integration Test $(date)" - popd - popd - - set +e - test_auth_failure "$(put_uri_with_private_key_and_tunnel_info "$(dirname "$0")/ssh/test_key" $TMPDIR/destination $TMPDIR/staging "$@" 2>&1)" -} - -init_integration_tests $basedir -run it_can_check_with_empty_tunnel_information -run_with_unauthenticated_proxy "$basedir" it_can_check_through_a_tunnel -run_with_unauthenticated_proxy "$basedir" it_can_get_through_a_tunnel -run_with_unauthenticated_proxy "$basedir" it_can_put_through_a_tunnel -run_with_unauthenticated_proxy "$basedir" it_can_check_through_a_tunnel_with_auth -run_with_unauthenticated_proxy "$basedir" it_can_get_through_a_tunnel_with_auth -run_with_unauthenticated_proxy "$basedir" it_can_put_through_a_tunnel_with_auth - -run_with_authenticated_proxy "$basedir" it_can_check_through_a_tunnel_with_auth -run_with_authenticated_proxy "$basedir" it_can_get_through_a_tunnel_with_auth -run_with_authenticated_proxy "$basedir" it_can_put_through_a_tunnel_with_auth -run_with_authenticated_proxy "$basedir" it_cant_check_through_a_tunnel_without_auth -run_with_authenticated_proxy "$basedir" it_cant_get_through_a_tunnel_without_auth -run_with_authenticated_proxy "$basedir" it_cant_put_through_a_tunnel_without_auth diff --git a/integration-tests/ssh/.gitignore b/integration-tests/ssh/.gitignore deleted file mode 100644 index 145f5d74..00000000 --- a/integration-tests/ssh/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test_* diff --git a/integration-tests/tunnel/auth b/integration-tests/tunnel/auth deleted file mode 100644 index 8a5c9a66..00000000 --- a/integration-tests/tunnel/auth +++ /dev/null @@ -1 +0,0 @@ -admin:admin diff --git a/integration-tests/tunnel/passwd b/integration-tests/tunnel/passwd deleted file mode 100644 index 0977a2a3..00000000 --- a/integration-tests/tunnel/passwd +++ /dev/null @@ -1 +0,0 @@ -admin:$apr1$qUcrUmJN$LCi7cragcviMqJ2g2OdAp1 diff --git a/integration-tests/tunnel/squid-auth.conf b/integration-tests/tunnel/squid-auth.conf deleted file mode 100644 index 59d4f4c7..00000000 --- a/integration-tests/tunnel/squid-auth.conf +++ /dev/null @@ -1,9 +0,0 @@ -auth_param basic program /usr/lib/squid/basic_ncsa_auth /tests/integration-tests/tunnel/passwd - -acl Safe_ports port 22 -acl authenticated proxy_auth REQUIRED -acl CONNECT method CONNECT -http_port 3128 - -http_access allow authenticated -http_access allow CONNECT Safe_ports diff --git a/integration-tests/tunnel/squid-noauth.conf b/integration-tests/tunnel/squid-noauth.conf deleted file mode 100644 index acca63ee..00000000 --- a/integration-tests/tunnel/squid-noauth.conf +++ /dev/null @@ -1,6 +0,0 @@ -acl Safe_ports port 22 -acl CONNECT method CONNECT - -http_port 3128 - -http_access allow CONNECT Safe_ports diff --git a/scripts/install_git_crypt.sh b/scripts/install_git_crypt.sh deleted file mode 100755 index 5f5ec037..00000000 --- a/scripts/install_git_crypt.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -eu - -_main() { - local tmpdir - tmpdir="$(mktemp -d git_crypt_install.XXXXXX)" - - cd "$tmpdir" - git clone https://github.com/AGWA/git-crypt.git - cd git-crypt - git checkout tags/0.7.0 - make - make install - cd ../.. - rm -rf "$tmpdir" -} - -_main "$@" diff --git a/scripts/test b/scripts/test deleted file mode 100755 index fe734574..00000000 --- a/scripts/test +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -e - -not_installed() { - ! command -v $1 > /dev/null 2>&1 -} - -git_resource_dir=$(cd $(dirname $0)/.. && pwd) - -if not_installed docker; then - echo "# docker is not installed! run the following commands:" - echo " brew install docker" - echo " brew cask install docker-machine" - echo " docker-machine create dev --driver virtualbox" - echo ' eval $(docker-machine env dev)' - echo " docker login" - exit 1 -fi - -cd $git_resource_dir -docker build --rm . diff --git a/test/all.sh b/test/all.sh deleted file mode 100755 index 1ce25d6d..00000000 --- a/test/all.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -e - -$(dirname $0)/image.sh -$(dirname $0)/check.sh -$(dirname $0)/check_branches.sh -$(dirname $0)/check_tags.sh -$(dirname $0)/get_branches.sh -$(dirname $0)/get_tags.sh -$(dirname $0)/common.sh -$(dirname $0)/get.sh -$(dirname $0)/put.sh -$(dirname $0)/lfs.sh - -echo -e '\e[32mall tests passed!\e[0m' diff --git a/test/check.sh b/test/check.sh deleted file mode 100755 index 64fcd7a3..00000000 --- a/test/check.sh +++ /dev/null @@ -1,1250 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -check_jq_functionality() { - # Ensure JQ correctly treats empty input as invalid - set +e - jq -e 'type == "string"' "$failed_output"; then - echo "checking should have failed" - return 1 - fi - - grep "source.uri is required and must not be empty" "$failed_output" -} - -it_errors_when_there_are_unknown_keys_in_source() { - local failed_output=$TMPDIR/unknown-keys-output - if check_uri_unknown_key "some-uri" 2>"$failed_output"; then - echo "checking should have failed" - return 1 - fi - - grep "Found unknown keys in source:" "$failed_output" - grep "some_key" "$failed_output" -} - -it_can_check_from_head() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - - check_uri $repo | jq -e " - . == [{ref: $(echo $ref | jq -R .)}] - " -} - -it_can_check_from_head_only_fetching_single_branch() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - - local cachedir="$TMPDIR/git-resource-repo-cache" - - check_uri_with_branch $repo "master" | jq -e " - . == [{ref: $(echo $ref | jq -R .)}] - " - - ! git -C $cachedir rev-parse origin/bogus -} - -it_fails_if_key_has_password_not_provided() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - - local key=$TMPDIR/key-with-passphrase - ssh-keygen -f $key -N some-passphrase - - local failed_output=$TMPDIR/failed-output - if check_uri_with_key $repo $key 2>$failed_output; then - echo "checking should have failed" - return 1 - fi - - grep "Private key has a passphrase but private_key_passphrase has not been set." $failed_output -} - -it_can_unlock_key_with_password() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local passphrase='some passphrase with spaces!' - - local key=$TMPDIR/key-with-passphrase - ssh-keygen -f $key -N "$passphrase" - - local failed_output=$TMPDIR/failed-output - check_uri_with_key_and_passphrase $repo $key "$passphrase" 2>$failed_output -} - - -it_configures_forward_agent() { - local repo=$(init_repo) - local key=$TMPDIR/key-no-passphrase - - ssh-keygen -f $key - check_uri_with_key_and_ssh_agent $repo $key true - - grep "ForwardAgent yes" $HOME/.ssh/config -} - -it_skips_forward_agent_configuration() { - local repo=$(init_repo) - local key=$TMPDIR/key-no-passphrase - - ssh-keygen -f $key - check_uri_with_key_and_ssh_agent $repo $key false - - ! grep "ForwardAgent" $HOME/.ssh/config -} - -it_configures_private_key_user() { - local repo=$(init_repo) - local key=$TMPDIR/key-no-passphrase - - ssh-keygen -f $key - check_uri_with_key_and_private_key_user $repo $key someuser - - grep "User someuser" $HOME/.ssh/config -} - -it_skips_private_key_user_configuration() { - local repo=$(init_repo) - local key=$TMPDIR/key-no-passphrase - - ssh-keygen -f $key - check_uri_with_key $repo $key - - ! grep "^User " $HOME/.ssh/config -} - -it_can_check_with_credentials() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - - check_uri_with_credentials $repo "user1" "pass1" | jq -e " - . == [{ref: $(echo $ref | jq -R .)}] - " - - # only check that the expected credential helper is set - # because it is not easily possible to simulate a git http backend that needs credentials - local expected_netrc="default login user1 password pass1" - [ "$(cat $HOME/.netrc)" = "$expected_netrc" ] - - # make sure it clears out .netrc for this request without credentials - check_uri_with_credentials $repo "" "" | jq -e " - . == [{ref: $(echo $ref | jq -R .)}] - " - [ ! -f "$HOME/.netrc" ] -} - -it_can_check_with_submodule_credentials() { - local repo=$(init_repo) - local ref=$(make_commit "$repo") - local expected_netrc - expected_netrc=$(cat < /dev/null - local ref1=$(make_commit_to_file $repo a/b/file) - check_uri_paths $repo "**/file" | jq -e " - . == [{ref: $(echo $ref1 | jq -R .)}] - " -} - -it_checks_given_ignored_paths() { - local repo=$(init_repo) - local ref1=$(make_commit_to_file $repo file-a) - local ref2=$(make_commit_to_file $repo file-b) - local ref3=$(make_commit_to_file $repo some-file) - - check_uri_paths_ignoring $repo 'file-*' 'file-b' | jq -e " - . == [{ref: $(echo $ref1 | jq -R .)}] - " - - check_uri_from_paths_ignoring $repo $ref1 'file-*' 'file-b' | jq -e " - . == [{ref: $(echo $ref1 | jq -R .)}] - " - - check_uri_from_paths_ignoring $repo $ref1 'file-*' 'file-a' | jq -e " - . == [{ref: $(echo $ref2 | jq -R .)}] - " - - local ref4=$(make_commit_to_file $repo file-b) - - check_uri_paths_ignoring $repo 'file-*' 'file-b' | jq -e " - . == [{ref: $(echo $ref1 | jq -R .)}] - " - - local ref5=$(make_commit_to_file $repo file-a) - - check_uri_paths_ignoring $repo 'file-*' 'file-b' | jq -e " - . == [{ref: $(echo $ref5 | jq -R .)}] - " - - local ref6=$(make_commit_to_file $repo file-c) - - local ref7=$(make_commit_to_file $repo some-file) - - check_uri_from_paths_ignoring $repo $ref1 'file-*' 'file-b' | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref5 | jq -R .)}, - {ref: $(echo $ref6 | jq -R .)} - ] - " - - check_uri_from_paths_ignoring $repo $ref1 'file-*' 'file-b' 'file-c' | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref5 | jq -R .)} - ] - " - local ref8=$(make_commit_to_file $repo another-file) - - check_uri_paths_ignoring $repo '*-file' 'another-file' | jq -e " - . == [ - {ref: $(echo $ref7 | jq -R .)} - ] - " - - check_uri_paths_ignoring $repo '.' 'file-*' | jq -e " - . == [ - {ref: $(echo $ref8 | jq -R .)} - ] - " -} - -it_can_check_when_not_ff() { - local repo=$(init_repo) - local other_repo=$(init_repo) - - local ref1=$(make_commit $repo) - local ref2=$(make_commit $repo) - - local ref3=$(make_commit $other_repo) - - check_uri $other_repo - - cd "$TMPDIR/git-resource-repo-cache" - - # do this so we get into a situation that git can't resolve by rebasing - git config branch.autosetuprebase never - - # set my remote to be the other git repo - git remote remove origin - git remote add origin $repo/.git - - # fetch so we have master available to track - git fetch - - # setup tracking for my branch - git branch -u origin/master HEAD - - check_uri $other_repo | jq -e " - . == [{ref: $(echo $ref2 | jq -R .)}] - " -} - -it_skips_marked_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit_to_be_skipped $repo) - local ref3=$(make_commit $repo "not ci skipped") - local ref4=$(make_commit_to_be_skipped2 $repo) - local ref5=$(make_commit $repo) - - check_uri_from $repo $ref1 | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref3 | jq -R .)}, - {ref: $(echo $ref5 | jq -R .)} - ] - " -} - -it_skips_marked_commits_with_no_version() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit_to_be_skipped $repo) - local ref3=$(make_commit_to_be_skipped2 $repo) - - check_uri $repo | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)} - ] - " -} - -it_skips_excluded_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit_to_future $repo "not skipped") - local ref3=$(make_commit $repo "should skip this commit") - local ref4=$(make_commit $repo) - - check_uri_with_filter $repo $ref1 "exclude" "should skip" | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref4 | jq -R .)} - ] - " -} - -it_skips_non_included_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit_to_future $repo "not skipped commit") - local ref3=$(make_commit $repo "not skipped commit number_two") - local ref4=$(make_commit $repo "should skip this commit") - local ref5=$(make_commit $repo) - - check_uri_with_filter $repo $ref1 "include" "not skipped" | jq -e " - . == [ - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref3 | jq -R .)} - ] - " -} - -it_skips_all_non_included_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit_to_future $repo "not skipped commit") - local ref3=$(make_commit $repo "not skipped commit number_two") - local ref4=$(make_commit $repo "should skip this commit") - local ref5=$(make_commit $repo) - - check_uri_with_filter $repo $ref1 "include" 'not\nskipped\nnumber_two' "true"| jq -e " - . == [ - {ref: $(echo $ref3 | jq -R .)} - ] - " -} - -it_skips_excluded_commits_conventional() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit $repo "chore: update a thing") - local ref3=$(make_commit $repo "chore(release): auto-publish") - local ref4=$(make_commit $repo "fix: a bug") - local ref5=$(make_commit $repo) - - check_uri_with_filter $repo $ref1 "exclude" "chore(release):" | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref4 | jq -R .)}, - {ref: $(echo $ref5 | jq -R .)} - ] - " -} - -it_skips_non_included_and_excluded_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit $repo "not skipped commit") - local ref3=$(make_commit $repo "not skipped sometimes") - local ref4=$(make_commit $repo) - - check_uri_with_filters $repo $ref1 "not skipped" "sometimes" | jq -e " - . == [ - {ref: $(echo $ref2 | jq -R .)} - ] - " -} - -it_rejects_filter_with_incorrect_format() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - - set +e - output=$( - jq --arg uri "$(init_repo)" \ - --arg ref "$(make_commit "$repo")" \ - -n '{ - source: { - $uri, - commit_filter: { - include: "a string, not an array", - } - }, - version: { - $ref - } - }' | ${resource_dir}/check | tee /dev/stderr - ) - exit_code=$? - set -e - - test $exit_code -ne 0 -} - -it_does_not_skip_marked_commits_when_disable_skip_configured() { - local repo=$(init_repo) - local ref1=$(make_commit_to_future $repo) - local ref2=$(make_commit_to_be_skipped $repo) - local ref3=$(make_commit $repo) - local ref4=$(make_commit_to_be_skipped2 $repo) - - check_uri_disable_ci_skip $repo $ref1 | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref3 | jq -R .)}, - {ref: $(echo $ref4 | jq -R .)} - ] - " -} - -it_can_check_empty_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_empty_commit $repo) - - check_uri_from $repo $ref1 | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref2 | jq -R .)} - ] - " -} - -it_can_check_from_head_with_empty_commits() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_empty_commit $repo) - - check_uri $repo | jq -e " - . == [{ref: $(echo $ref2 | jq -R .)}] - " -} - -it_can_check_with_tag_filter() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "tag 1") - local ref3=$(make_commit $repo) - local ref4=$(make_annotated_tag $repo "1.0-production" "tag 2") - local ref5=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref6=$(make_commit $repo) - local ref7=$(make_annotated_tag $repo "2.0-staging" "tag 5") - local ref8=$(make_commit $repo) - local ref9=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref10=$(make_commit $repo) - - check_uri_with_tag_filter $repo "*-staging" | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref6\"}] - " -} - -it_can_check_with_tag_and_path_match_filter() { - local repo=$(init_repo) - local ref1=$(make_commit_to_file $repo file-a) - local ref2=$(make_annotated_tag $repo "1.0-staging" "tag 1" true) - local ref3=$(make_commit_to_file $repo file-b) - local ref4=$(make_annotated_tag $repo "1.0-production" "tag 2" true) - local ref5=$(make_annotated_tag $repo "2.0-staging" "tag 3" true) - local ref6=$(make_commit_to_file $repo file-c) - local ref7=$(make_annotated_tag $repo "2.0-staging" "tag 5" true) - local ref8=$(make_commit_to_file $repo file-b) - local ref9=$(make_annotated_tag $repo "2.0-production" "tag 4" true) - local ref10=$(make_commit_to_file $repo file-c) - - check_uri_with_tag_and_path_filter $repo "2*" "match_tagged" file-c | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref6\"}] - " - - # No matching files. ref3's tag was replaced by the tag on ref6 - which does not path match - check_uri_with_tag_and_path_filter $repo "*-staging" "match_tagged" file-b | jq -e " - . == [] - " - - # Although multiple tagged commits modify the files, ref8 is the latest (and version_depth is default 1) - check_uri_with_tag_and_path_filter $repo "*" "match_tagged" file-b file-c | jq -e " - . == [ - {ref: \"2.0-production\", commit: \"$ref8\"} - ] - " - - # file-f was never created - check_uri_with_tag_and_path_filter $repo "*" "match_tagged" file-f | jq -e " - . == [] - " - - # no tags matching 4.0-* - check_uri_with_tag_and_path_filter $repo "4.0-*" "match_tagged" file-c | jq -e " - . == [] - " -} - -it_can_check_with_tag_and_path_match_ancestors_filter() { - local repo=$(init_repo) - local ref1=$(make_commit_to_file $repo file-a) - local ref2=$(make_annotated_tag $repo "1.0-staging" "tag 1" true) - local ref3=$(make_commit_to_file $repo file-b) - local ref4=$(make_annotated_tag $repo "1.0-production" "tag 2" true) - local ref5=$(make_annotated_tag $repo "2.0-staging" "tag 3" true) - local ref6=$(make_commit_to_file $repo file-c) - local ref7=$(make_annotated_tag $repo "2.0-staging" "tag 5" true) - local ref8=$(make_commit_to_file $repo file-b) - local ref9=$(make_annotated_tag $repo "2.0-production" "tag 4" true) - local ref10=$(make_commit_to_file $repo file-c) - - # ref10 is the most recent to modify file-c, but the latest 2* tag is before it. Therefore ref6 matches. - check_uri_with_tag_and_path_filter $repo "2*" "match_tag_ancestors" file-c | jq -e " - . == [{ref: \"$ref6\"}] - " - - # ref3 is the most recent commit to modify file-b, and following commits have -staging tags - check_uri_with_tag_and_path_filter $repo "*-staging" "match_tag_ancestors" file-b | jq -e " - . == [{ref: \"$ref3\"}] - " - - # although no 2.* tagged commits modified file-a, they follow on from commits that did - check_uri_with_tag_and_path_filter $repo "2.*" "match_tag_ancestors" file-a | jq -e " - . == [{ref: \"$ref1\"}] - " - - # no commits creating file-c are followed by 1.* tags - check_uri_with_tag_and_path_filter $repo "1.*" "match_tag_ancestors" file-c | jq -e " - . == [] - " - - # Although multiple tagged commits modify the files, ref8 is the latest (and version_depth is default 1) - check_uri_with_tag_and_path_filter $repo "*" "match_tag_ancestors" file-b file-c | jq -e " - . == [ - {ref: \"$ref8\"} - ] - " - - # file-f was never created - check_uri_with_tag_and_path_filter $repo "*" "match_tag_ancestors" file-f | jq -e " - . == [] - " - - # no tags matching 4.0-* - check_uri_with_tag_and_path_filter $repo "4.0-*" "match_tag_ancestors" file-c | jq -e " - . == [] - " -} - -it_can_check_with_tag_regex() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "tag 1") - local ref3=$(make_commit $repo) - local ref4=$(make_annotated_tag $repo "1.0-production" "tag 2") - local ref5=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref6=$(make_commit $repo) - local ref7=$(make_annotated_tag $repo "2.0-staging" "tag 5") - local ref8=$(make_commit $repo) - local ref9=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref10=$(make_commit $repo) - - check_uri_with_tag_regex $repo ".*-staging" | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref6\"}] - " -} - -it_can_check_with_tag_filter_with_cursor() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "a tag") - local ref3=$(make_commit $repo) - local ref4=$(make_annotated_tag $repo "1.0-production" "another tag") - local ref5=$(make_commit $repo) - local ref6=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref7=$(make_commit $repo) - local ref8=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref9=$(make_commit $repo) - local ref10=$(make_annotated_tag $repo "3.0-staging" "tag 5") - local ref11=$(make_commit $repo) - local ref12=$(make_annotated_tag $repo "3.0-production" "tag 6") - local ref13=$(make_commit $repo) - - x=$(check_uri_with_tag_filter_from $repo "*-staging" "2.0-staging") - check_uri_with_tag_filter_from $repo "*-staging" "2.0-staging" 2 | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref5\"}, {ref: \"3.0-staging\", commit: \"$ref9\"}] - " -} - -it_can_check_with_tag_regex_with_cursor() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "a tag") - local ref3=$(make_commit $repo) - local ref4=$(make_annotated_tag $repo "1.0-production" "another tag") - local ref5=$(make_commit $repo) - local ref6=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref7=$(make_commit $repo) - local ref8=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref9=$(make_commit $repo) - local ref10=$(make_annotated_tag $repo "3.0-staging" "tag 5") - local ref11=$(make_commit $repo) - local ref12=$(make_annotated_tag $repo "3.0-production" "tag 6") - local ref13=$(make_commit $repo) - - x=$(check_uri_with_tag_regex_from $repo ".*-staging" "2.0-staging") - check_uri_with_tag_regex_from $repo ".*-staging" "2.0-staging" 2 | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref5\"}, {ref: \"3.0-staging\", commit: \"$ref9\"}] - " -} - -it_can_check_with_tag_filter_over_all_branches() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "1.0-staging" "a tag") - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_annotated_tag $repo "1.0-production" "another tag") - local ref5=$(make_commit_to_branch $repo branch-a) - local ref6=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref7=$(make_commit_to_branch $repo branch-a) - local ref8=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref9=$(make_commit_to_branch $repo branch-a) - local ref10=$(make_annotated_tag $repo "3.0-staging" "tag 5") - local ref11=$(make_commit_to_branch $repo branch-a) - local ref12=$(make_annotated_tag $repo "3.0-production" "tag 6") - local ref13=$(make_commit_to_branch $repo branch-a) - - check_uri_with_tag_filter $repo "*-staging" | jq -e " - . == [{ref: \"3.0-staging\", commit: \"$ref9\"}] - " -} - -it_can_check_with_tag_regex_over_all_branches() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "1.0-staging" "a tag") - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_annotated_tag $repo "1.0-production" "another tag") - local ref5=$(make_commit_to_branch $repo branch-a) - local ref6=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref7=$(make_commit_to_branch $repo branch-a) - local ref8=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref9=$(make_commit_to_branch $repo branch-a) - local ref10=$(make_annotated_tag $repo "3.0-staging" "tag 5") - local ref11=$(make_commit_to_branch $repo branch-a) - local ref12=$(make_annotated_tag $repo "3.0-production" "tag 6") - local ref13=$(make_commit_to_branch $repo branch-a) - - check_uri_with_tag_regex $repo ".*-staging" | jq -e " - . == [{ref: \"3.0-staging\", commit: \"$ref9\"}] - " -} - -it_can_check_with_tag_filter_over_all_branches_with_cursor() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "1.0-staging" "a tag") - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_annotated_tag $repo "1.0-production" "another tag") - local ref5=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref6=$(make_commit_to_branch $repo branch-a) - local ref7=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref8=$(make_commit_to_branch $repo branch-a) - local ref9=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref10=$(make_commit_to_branch $repo branch-a) - local ref11=$(make_annotated_tag $repo "3.0-staging" "tag 5") - local ref12=$(make_commit_to_branch $repo branch-a) - local ref13=$(make_annotated_tag $repo "3.0-production" "tag 6") - local ref14=$(make_commit_to_branch $repo branch-a) - - check_uri_with_tag_filter_from $repo "*-staging" "2.0-staging" 2 | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref6\"}, {ref: \"3.0-staging\", commit: \"$ref10\"}] - " -} - -it_can_check_with_tag_regex_over_all_branches_with_cursor() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "1.0-staging" "a tag") - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_annotated_tag $repo "1.0-production" "another tag") - local ref5=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref6=$(make_commit_to_branch $repo branch-a) - local ref7=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref8=$(make_commit_to_branch $repo branch-a) - local ref9=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref10=$(make_commit_to_branch $repo branch-a) - local ref11=$(make_annotated_tag $repo "3.0-staging" "tag 5") - local ref12=$(make_commit_to_branch $repo branch-a) - local ref13=$(make_annotated_tag $repo "3.0-production" "tag 6") - local ref14=$(make_commit_to_branch $repo branch-a) - - check_uri_with_tag_regex_from $repo ".*-staging" "2.0-staging" 2 | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref6\"}, {ref: \"3.0-staging\", commit: \"$ref10\"}] - " -} - -it_can_check_with_tag_filter_with_bogus_ref() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "tag 1") - local ref3=$(make_commit $repo) - local ref4=$(make_annotated_tag $repo "1.0-production" "tag 2") - local ref5=$(make_commit $repo) - local ref6=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref7=$(make_commit $repo) - local ref8=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref9=$(make_commit $repo) - - - check_uri_with_tag_filter_from $repo "*-staging" "bogus-ref" | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref5\"}] - " -} - -it_can_check_with_tag_regex_with_bogus_ref() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "tag 1") - local ref3=$(make_commit $repo) - local ref4=$(make_annotated_tag $repo "1.0-production" "tag 2") - local ref5=$(make_commit $repo) - local ref6=$(make_annotated_tag $repo "2.0-staging" "tag 3") - local ref7=$(make_commit $repo) - local ref8=$(make_annotated_tag $repo "2.0-production" "tag 4") - local ref9=$(make_commit $repo) - - - check_uri_with_tag_regex_from $repo ".*-staging" "bogus-ref" | jq -e " - . == [{ref: \"2.0-staging\", commit: \"$ref5\"}] - " -} - -it_can_check_with_tag_filter_with_replaced_tags() { - - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "staging" "tag branch-a") - # see that the tag is initially ref1 - check_uri_with_tag_filter $repo "staging" | jq -e " - . == [{ref: \"staging\", commit: \"$ref1\"}] - " - - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_annotated_tag $repo "staging" "tag branch-a") - - check_uri_with_tag_filter $repo "staging" | jq -e " - . == [{ref: \"staging\", commit: \"$ref3\"}] - " -} - -it_can_check_with_tag_regex_with_replaced_tags() { - - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "staging" "tag branch-a") - # see that the tag is initially ref1 - check_uri_with_tag_regex $repo "staging" | jq -e " - . == [{ref: \"staging\", commit: \"$ref1\"}] - " - - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_annotated_tag $repo "staging" "tag branch-a") - - check_uri_with_tag_regex $repo "staging" | jq -e " - . == [{ref: \"staging\", commit: \"$ref3\"}] - " -} - -it_can_check_with_tag_filter_given_branch_first_ref() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "test.tag.1" "tag branch-a") - # see that the tag on non-master branch doesn't get picked up - check_uri_with_tag_filter_given_branch $repo "test.tag.*" "master" | jq -e " - . == [] - " - - # make a new tag on master, ensure it gets picked up - local ref3=$(make_commit_to_branch $repo master) - local ref4=$(make_annotated_tag $repo "test.tag.2" "tag branch-a") - - check_uri_with_tag_filter_given_branch $repo "test.tag.*" "master" | jq -e " - . == [{ref: \"test.tag.2\", commit: \"$ref3\"}] - " -} - -it_can_check_with_tag_regex_given_branch_first_ref() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "test.tag.1" "tag branch-a") - # see that the tag on non-master branch doesn't get picked up - check_uri_with_tag_regex_given_branch $repo "test.tag\..*" "master" | jq -e " - . == [] - " - - # make a new tag on master, ensure it gets picked up - local ref3=$(make_commit_to_branch $repo master) - local ref4=$(make_annotated_tag $repo "test.tag.2" "tag branch-a") - - check_uri_with_tag_regex_given_branch $repo "test.tag\..*" "master" | jq -e " - . == [{ref: \"test.tag.2\", commit: \"$ref3\"}] - " -} - -it_can_check_and_set_git_config() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - - cp ~/.gitconfig ~/.gitconfig.orig - - check_uri_with_config $repo | jq -e " - . == [{ref: $(echo $ref | jq -R .)}] - " - test "$(git config --global core.pager)" == 'true' - test "$(git config --global credential.helper)" == '!true long command with variables $@' - - mv ~/.gitconfig.orig ~/.gitconfig -} - -it_checks_lastest_commit() { - local repo=$(init_repo) - local ref1=$(make_commit_to_future $repo) - local ref2=$(make_commit $repo) - - check_uri $repo | jq -e " - . == [{ref: $(echo $ref2 | jq -R .)}] - " -} - -it_can_check_a_repo_having_multiple_root_commits() { - local repo=$(init_repo) - local ref1=$(get_initial_ref $repo) - local ref2=$(make_commit $repo) - - # Make the second root commit, the commit tree will look like: - # - # * ref3 - # |\ - # | * second root - # * ref2 - # * ref1 - # - # Where ref1 is the first commit of the repo, and "second root" is created - # to simulator the issue in https://github.com/concourse/git-resource/pull/324, - # that is also a root commit. - git -C $repo checkout --orphan temp $ref2 - git -C $repo commit -m "second root" --allow-empty - git -C $repo checkout master - git -C $repo merge temp --allow-unrelated-histories -m "merge commit" - ref3=$(git -C $repo rev-parse HEAD) - - check_uri_from $repo $ref1 | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref3 | jq -R .)} - ] - " -} - -it_can_check_a_repo_having_multiple_root_commits_from_the_orphan_commit() { - local repo=$(init_repo) - local ref1=$(get_initial_ref $repo) - local ref2=$(make_commit $repo) - - # Same as above, but where the current version is the orphan commit. - git -C $repo checkout --orphan temp $ref2 - git -C $repo commit -m "second root" --allow-empty - git -C $repo checkout master - git -C $repo merge temp --allow-unrelated-histories -m "merge commit" - second_root=$(git -C $repo rev-parse HEAD^2) - ref3=$(git -C $repo rev-parse HEAD) - - check_uri_from $repo $second_root | jq -e " - . == [ - {ref: $(echo $ref1 | jq -R .)}, - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref3 | jq -R .)} - ] - " -} - -it_checks_with_version_depth() { - local repo=$(init_repo) - local ref1=$(make_commit_to_future $repo) - local ref2=$(make_commit $repo) - local ref3=$(make_commit $repo) - check_uri_with_version_depth $repo 2 | jq -e " - . == [ - {ref: $(echo $ref2 | jq -R .)}, - {ref: $(echo $ref3 | jq -R .)} - ] - " -} - -it_checks_uri_with_tag_filter_and_version_depth() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - make_annotated_tag $repo "test.tag.1" "tag ref1" - local ref2=$(make_commit $repo) - make_annotated_tag $repo "test.tag.2" "tag ref2" - local ref3=$(make_commit $repo) - make_annotated_tag $repo "test.badtag.3" "tag ref3" - local ref4=$(make_commit $repo) - make_annotated_tag $repo "test.tag.4" "tag ref4" - check_uri_with_tag_filter_and_version_depth $repo 2 "test.tag.*" | jq -e " - . == [ - { - ref: \"test.tag.2\", - commit: $(echo $ref2 | jq -R .) - }, - { - ref: \"test.tag.4\", - commit: $(echo $ref4 | jq -R .) - } - ]" -} - -it_can_check_tags_on_unmerged_branches() { - local repo=$(init_repo) - - # Initial setup - populate with no matching tags - local ref1=$(make_commit_to_branch $repo master) - rm -rf $TMPDIR/git-resource-repo-cache - check_uri_with_tag_filter $repo "v*-hotfix" | jq -e ". == []" - - # Create tag on divergent branch after cache exists - local ref2=$(make_commit_to_branch $repo hotfix) - local ref3=$(make_annotated_tag $repo "v1.0.0-hotfix" "hotfix tag") - - # More commits on master - branch stays unmerged - local ref4=$(make_commit_to_branch $repo master) - - # Should find tag via fetch (tests fetch path) - check_uri_with_tag_filter $repo "v*-hotfix" | jq -e " - . == [{ref: \"v1.0.0-hotfix\", commit: \"$ref2\"}] - " - - # Clear cache and verify clone path also works - rm -rf $TMPDIR/git-resource-repo-cache - check_uri_with_tag_regex $repo "v.*-hotfix" | jq -e " - . == [{ref: \"v1.0.0-hotfix\", commit: \"$ref2\"}] - " -} - -run check_jq_functionality -run it_can_check_from_head -run it_can_check_from_a_ref -run it_can_check_from_a_first_commit_in_repo -run it_can_check_from_a_bogus_sha -run it_skips_ignored_paths -run it_checks_given_paths -run it_checks_given_paths_ci_skip_disabled -run it_checks_given_paths_on_branch -run it_checks_given_glob_paths -run it_checks_given_ignored_paths -run it_can_check_when_not_ff -run it_skips_marked_commits -run it_skips_marked_commits_with_no_version -run it_skips_excluded_commits -run it_skips_excluded_commits_conventional -run it_skips_non_included_commits -run it_skips_non_included_and_excluded_commits -run it_rejects_filter_with_incorrect_format -run it_skips_all_non_included_commits -run it_does_not_skip_marked_commits_when_disable_skip_configured -run it_fails_if_key_has_password_not_provided -run it_can_unlock_key_with_password -run it_configures_forward_agent -run it_skips_forward_agent_configuration -run it_can_check_with_credentials -run it_can_check_with_submodule_credentials -run it_scopes_credentials_to_credential_hosts -run it_clears_netrc_even_after_errors -run it_can_check_empty_commits -run it_can_check_with_tag_filter -run it_can_check_with_tag_regex -run it_can_check_with_tag_filter_with_cursor -run it_can_check_with_tag_regex_with_cursor -run it_can_check_with_tag_filter_over_all_branches -run it_can_check_with_tag_regex_over_all_branches -run it_can_check_with_tag_filter_over_all_branches_with_cursor -run it_can_check_with_tag_regex_over_all_branches_with_cursor -run it_can_check_with_tag_filter_with_bogus_ref -run it_can_check_with_tag_regex_with_bogus_ref -run it_can_check_with_tag_filter_with_replaced_tags -run it_can_check_with_tag_regex_with_replaced_tags -run it_can_check_with_tag_and_path_match_filter -run it_can_check_with_tag_and_path_match_ancestors_filter -run it_can_check_from_head_only_fetching_single_branch -run it_can_check_and_set_git_config -run it_can_check_from_a_ref_and_only_show_merge_commit -run it_can_check_from_a_ref_with_paths_merged_in -run it_can_check_with_tag_filter_given_branch_first_ref -run it_can_check_with_tag_regex_given_branch_first_ref -run it_checks_lastest_commit -run it_can_check_a_repo_having_multiple_root_commits -run it_can_check_a_repo_having_multiple_root_commits_from_the_orphan_commit -run it_checks_with_version_depth -run it_checks_uri_with_tag_filter_and_version_depth -run it_errors_when_uri_is_empty -run it_errors_when_there_are_unknown_keys_in_source -run it_can_check_tags_on_unmerged_branches -run it_configures_private_key_user -run it_skips_private_key_user_configuration \ No newline at end of file diff --git a/test/check_branches.sh b/test/check_branches.sh deleted file mode 100755 index ee0e21e2..00000000 --- a/test/check_branches.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -it_returns_all_branches() { - # init_repo already creates master and bogus; add a third branch - local repo=$(init_repo) - make_commit_to_branch $repo develop >/dev/null - - check_uri_with_branches $repo | jq -e ' - .[0].branches == "bogus,develop,master" - ' -} - -it_sorts_branches() { - local repo=$(init_repo) - make_commit_to_branch $repo feat/qwer >/dev/null - make_commit_to_branch $repo feat/hjkl >/dev/null - make_commit_to_branch $repo feat/wasd >/dev/null - make_commit_to_branch $repo feat/abcd >/dev/null - - # bogus and master are created by init_repo and sort around the feat/* branches - check_uri_with_branches $repo | jq -e ' - .[0].branches == "bogus,feat/abcd,feat/hjkl,feat/qwer,feat/wasd,master" - ' -} - -it_errors_if_branch_filters_and_branch_regex_are_set() { - local repo=$(init_repo) - local failed_output=$TMPDIR/filters-and-regex-output - - if check_uri_with_branch_filters_and_regex $repo "feat/.*" "feat/*" 2>"$failed_output"; then - echo "checking should have failed" - return 1 - fi - - grep "only one of branch_filters or branch_regex can be specified" "$failed_output" -} - -it_uses_all_branch_filters() { - local repo=$(init_repo) - make_commit_to_branch $repo issue/hjkl >/dev/null - make_commit_to_branch $repo feat/oiuy >/dev/null - make_commit_to_branch $repo bug/876 >/dev/null - make_commit_to_branch $repo refactor/ui >/dev/null - - check_uri_with_branch_filters $repo "bug/*" "issue/*" | jq -e ' - .[0].branches == "bug/876,issue/hjkl" - ' -} - -it_uses_branch_regex() { - local repo=$(init_repo) - make_commit_to_branch $repo issue/hjkl >/dev/null - make_commit_to_branch $repo feat/oiuy >/dev/null - make_commit_to_branch $repo bug/876 >/dev/null - make_commit_to_branch $repo refactor/ui >/dev/null - - check_uri_with_branch_regex $repo '(refactor\/|feat\/).*' | jq -e ' - .[0].branches == "feat/oiuy,refactor/ui" - ' -} - -it_returns_empty_array_when_no_new_branches() { - # init_repo already creates two branches: master and bogus - local repo=$(init_repo) - - local branches=$(check_uri_with_branches $repo | jq -r '.[0].branches') - - check_uri_with_branches_from $repo "$branches" | jq -e '. == []' -} - -it_returns_none_when_no_branches_found() { - local repo=$(init_repo) - - # only master and bogus branch exist, therefore no matching branches should be found - check_uri_with_branch_filters $repo "issue/*" | jq -e ' - .[0].branches == "NONE" - ' -} - -run it_returns_all_branches -run it_sorts_branches -run it_errors_if_branch_filters_and_branch_regex_are_set -run it_uses_all_branch_filters -run it_uses_branch_regex -run it_returns_empty_array_when_no_new_branches -run it_returns_none_when_no_branches_found diff --git a/test/check_tags.sh b/test/check_tags.sh deleted file mode 100755 index b1bba918..00000000 --- a/test/check_tags.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -it_gets_all_tags() { - local repo=$(init_repo) - make_annotated_tag $repo foo "tag foo" true >/dev/null - make_annotated_tag $repo bar "tag bar" true >/dev/null - make_annotated_tag $repo wasd "tag wasd" true >/dev/null - make_lightweight_tag $repo other true >/dev/null - - check_uri_with_tags $repo | jq -e 'map(.tag) == ["foo","bar","wasd","other"] and all(.[]; (.ref // "") != "")' -} - -it_uses_tag_filter() { - local repo=$(init_repo) - make_annotated_tag $repo foo-1 "tag foo-1" true >/dev/null - make_annotated_tag $repo foo-2 "tag foo-2" true >/dev/null - make_annotated_tag $repo wasd "tag wasd" true >/dev/null - make_annotated_tag $repo 3-foo "tag 3-foo" true >/dev/null - make_lightweight_tag $repo foo-4 true >/dev/null - make_lightweight_tag $repo qwerty true >/dev/null - make_lightweight_tag $repo 5-foo true >/dev/null - - check_uri_with_tags_filter $repo "foo-*" | jq -e 'map(.tag) == ["foo-1","foo-2","foo-4"] and all(.[]; (.ref // "") != "")' -} - -it_uses_tag_filters() { - local repo=$(init_repo) - make_annotated_tag $repo foo-1 "tag foo-1" true >/dev/null - make_annotated_tag $repo foo-2 "tag foo-2" true >/dev/null - make_annotated_tag $repo wasd "tag wasd" true >/dev/null - make_annotated_tag $repo 3-foo "tag 3-foo" true >/dev/null - make_lightweight_tag $repo foo-4 true >/dev/null - make_lightweight_tag $repo qwerty true >/dev/null - make_lightweight_tag $repo 5-foo true >/dev/null - - check_uri_with_tags_filter $repo "foo-*" | jq -e 'map(.tag) == ["foo-1","foo-2","foo-4"] and all(.[]; (.ref // "") != "")' -} - -it_combines_tag_filter_and_tag_filters() { - local repo=$(init_repo) - make_annotated_tag $repo foo-1 "tag foo-1" true >/dev/null - make_annotated_tag $repo foo-2 "tag foo-2" true >/dev/null - make_annotated_tag $repo wasd "tag wasd" true >/dev/null - make_annotated_tag $repo 3-foo "tag 3-foo" true >/dev/null - make_lightweight_tag $repo foo-4 true >/dev/null - make_lightweight_tag $repo qwerty true >/dev/null - make_lightweight_tag $repo 5-foo true >/dev/null - - check_uri_with_tags_filter_and_filters $repo "*-foo" "foo-*" \ - | jq -e 'map(.tag) == ["foo-1","foo-2","3-foo","foo-4","5-foo"] and all(.[]; (.ref // "") != "")' -} - -it_uses_tag_regex() { - local repo=$(init_repo) - make_annotated_tag $repo foo-1 "tag foo-1" true >/dev/null - make_annotated_tag $repo foo-2 "tag foo-2" true >/dev/null - make_annotated_tag $repo wasd "tag wasd" true >/dev/null - make_annotated_tag $repo 3-foo "tag 3-foo" true >/dev/null - make_lightweight_tag $repo foo-4 true >/dev/null - make_lightweight_tag $repo qwerty true >/dev/null - make_lightweight_tag $repo 5-foo true >/dev/null - - check_uri_with_tags_regex $repo "foo-.*" | jq -e 'map(.tag) == ["foo-1","foo-2","foo-4"] and all(.[]; (.ref // "") != "")' -} - -it_sorts_by_version() { - local repo=$(init_repo) - make_annotated_tag $repo v1.1.0 "tag v1.1.0" >/dev/null - make_annotated_tag $repo v1.2.0 "tag v1.2.0" >/dev/null - make_annotated_tag $repo v1.1.1 "tag v1.1.1" >/dev/null - make_annotated_tag $repo v1.1.2 "tag v1.1.2" >/dev/null - make_annotated_tag $repo v1.2.1 "tag v1.2.1" >/dev/null - make_lightweight_tag $repo v1.3.0 true >/dev/null - make_lightweight_tag $repo v1.3.1 true >/dev/null - - check_uri_with_tags_sort $repo "version" \ - | jq -e 'map(.tag) == ["v1.1.0","v1.1.1","v1.1.2","v1.2.0","v1.2.1","v1.3.0","v1.3.1"] and all(.[]; (.ref // "") != "")' -} - -it_returns_new_tags() { - local repo=$(init_repo) - make_annotated_tag $repo v1.1.0 "tag v1.1.0" >/dev/null - make_annotated_tag $repo v1.2.0 "tag v1.2.0" >/dev/null - make_annotated_tag $repo v1.1.1 "tag v1.1.1" >/dev/null - make_annotated_tag $repo v1.1.2 "tag v1.1.2" >/dev/null - make_annotated_tag $repo v1.2.1 "tag v1.2.1" >/dev/null - make_lightweight_tag $repo v1.3.0 true >/dev/null - make_lightweight_tag $repo v1.3.1 true >/dev/null - - check_uri_with_tags_sort_from $repo "version" "v1.2.0" \ - | jq -e 'map(.tag) == ["v1.2.0","v1.2.1","v1.3.0","v1.3.1"] and all(.[]; (.ref // "") != "")' -} - -it_finds_no_tags() { - local repo=$(init_repo) - - check_uri_with_tags $repo | jq -e '. == []' -} - -it_returns_no_tags_due_to_filtering() { - local repo=$(init_repo) - make_annotated_tag $repo foo-1 "tag foo-1" true >/dev/null - - check_uri_with_tags_filter $repo "nomatch*" | jq -e '. == []' -} - -run it_gets_all_tags -run it_uses_tag_filter -run it_uses_tag_filters -run it_combines_tag_filter_and_tag_filters -run it_uses_tag_regex -run it_sorts_by_version -run it_returns_new_tags -run it_finds_no_tags -run it_returns_no_tags_due_to_filtering diff --git a/test/common.sh b/test/common.sh deleted file mode 100755 index 46146bcd..00000000 --- a/test/common.sh +++ /dev/null @@ -1,541 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh -source /opt/resource/common.sh - -it_has_no_url_in_metadata_when_remote_is_not_configured() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - cd $repo - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 0 -} - -it_has_no_url_in_metadata_when_remote_is_not_known() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - - # set an unrecognized origin - cd $repo - git remote add origin git@whoknows.com:some/path/repo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 0 -} - -it_has_url_in_metadata_when_remote_is_github_scp() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://github.com/myorg/myrepo/commit/$ref" - - # set a github origin - cd $repo - git remote add origin git@github.com:myorg/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl - -} - -it_has_url_in_metadata_when_remote_is_github_ssh() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://github.com/myorg/myrepo/commit/$ref" - - # set a github origin - cd $repo - git remote add origin ssh://git@github.com/myorg/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl -} - -it_has_url_in_metadata_when_remote_is_github_ssh_over_443() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://github.com:443/myorg/myrepo/commit/$ref" - - # set a github origin - cd $repo - git remote add origin ssh://git@github.com:443/myorg/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl -} - -it_has_url_in_metadata_when_remote_is_github_https() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://github.com/myorg/myrepo/commit/$ref" - - # set a github origin - cd $repo - git remote add origin https://github.com/myorg/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl -} - -it_has_url_in_metadata_when_remote_is_likely_github_enterprise() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://github.company.com/myorg/myrepo/commit/$ref" - - # set a github enterprise origin - cd $repo - git remote add origin https://github.company.com/myorg/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl -} - -it_has_url_in_metadata_when_remote_is_gitlab() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://gitlab.com/myorg/mygroup/myrepo/-/commit/$ref" - - # set a gitlab origin with nested groups - cd $repo - git remote add origin https://gitlab.com/myorg/mygroup/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl -} - -it_has_url_in_metadata_when_remote_is_bitbucket() { - local repo=$(init_repo) - local ref=$(make_commit $repo "") - local expectedUrl="https://bitbucket.com/myteam/myrepo/commits/$ref" - - # set a bitbucket ssh origin - cd $repo - git remote add origin ssh://git@bitbucket.com/myteam/myrepo.git - - test $(git_metadata | jq -r '. | map(select(.name == "url")) | length') = 1 - test $(git_metadata | jq -r '.[] | select(.name == "url") | .value') = $expectedUrl -} - -it_truncates_large_messages() { - local repo=$(init_repo) - local message=$(cat /dev/urandom | tr -dc A-Z | head -c 20000 ; echo '') - local ref=$(make_commit $repo $message) - cd $repo - - test $(git_metadata | jq -r '.[] | select(.name == "message") | .value' | wc -m) = 10241 -} - -it_creates_github_app_jwt() { - local client_id="some_client_id" - local pem=$(get_github_app_private_key) - local iat="1787583518" - local exp="1787584178" - local jwt=$(create_github_app_jwt "$client_id" "$pem" "$iat" "$exp") - - local header_schema='{ - "typ": "", - "alg": "" - }' - local payload_schema='{ - "iat": "", - "exp": "", - "iss": "" - }' - - # extract segments, fix padding, and decode - local header_json=$(echo -n "$jwt" | cut -d'.' -f1 | sed 's/-/+/g; s/_/\//g' | awk '{ ext = length($0) % 4; if (ext == 2) { print $0 "==" } else if (ext == 3) { print $0 "=" } else { print $0 } }' | base64 -d) - local payload_json=$(echo -n "$jwt" | cut -d'.' -f2 | sed 's/-/+/g; s/_/\//g' | awk '{ ext = length($0) % 4; if (ext == 2) { print $0 "==" } else if (ext == 3) { print $0 "=" } else { print $0 } }' | base64 -d) - - # validate there are no unknown keys - local unknown_header_keys=$(echo "$header_schema" "$header_json" | jq --slurp '(.[0] | keys_unsorted) - (.[1] | keys_unsorted)') - test $(jq -r 'length > 0' <<< $unknown_header_keys) = "false" - local unknown_payload_keys=$(echo "$payload_schema" "$payload_json" | jq --slurp '(.[0] | keys_unsorted) - (.[1] | keys_unsorted)') - test $(jq -r 'length > 0' <<< $unknown_payload_keys) = "false" - - # validate expected header values - test $(jq -r .typ <<< "$header_json") = "JWT" - test $(jq -r .alg <<< "$header_json") = "RS256" - - # validate expected payload values - test $(jq -r .iat <<< "$payload_json") = "1787583518" - test $(jq -r .exp <<< "$payload_json") = "1787584178" - test $(jq -r .iss <<< "$payload_json") = "some_client_id" - - # keep the signature in base64 - local signature=$(echo -n "$jwt" | cut -d'.' -f3) - test -n "$signature" - - # get the header and payload segments as a single string, we know it has what we expect - # due to above tests, verify the signature - local header_and_payload=$(echo -n "$jwt" | cut -d'.' -f1,2) - local expected_signature=$(openssl dgst -sha256 -sign <(echo -n "${pem}") <(echo -n "${header_and_payload}") | base64 | tr -d '=' | tr '/+' '_-' | tr -d '\n') - test -n "$expected_signature" - test "$signature" = "$expected_signature" -} - -it_gets_github_app_install_id_when_user_set() { - local base_api_url="https://api.company.ghe.com" - local jwt="my-jwt" - local org="" - local user="company_user" - local repo="" - - curl() { - test "${5}" = "-s" || return 1 - test "${6}" = "-X" || return 1 - test "${7}" = "GET" || return 1 - test "${8}" = "-H" || return 1 - test "${9}" = "Accept: application/vnd.github+json" || return 1 - test "${10}" = "-H" || return 1 - test "${11}" = "X-GitHub-Api-Version: 2026-03-10" || return 1 - test "${12}" = "-H" || return 1 - test "${13}" = "Authorization: Bearer my-jwt" || return 1 - test "${14}" = "https://api.company.ghe.com/users/company_user/installation" || return 1 - - echo '{"id": 999911}' - } - test $(get_github_app_install_id "$base_api_url" "$jwt" "$org" "$user" "$repo") = 999911 - unset curl -} - -it_gets_github_app_install_id_when_org_set() { - local base_api_url="https://api.something.ghe.com" - local jwt="fakejwt" - local org="an_org" - local user="" - local repo="" - - curl() { - test "${5}" = "-s" || return 1 - test "${6}" = "-X" || return 1 - test "${7}" = "GET" || return 1 - test "${8}" = "-H" || return 1 - test "${9}" = "Accept: application/vnd.github+json" || return 1 - test "${10}" = "-H" || return 1 - test "${11}" = "X-GitHub-Api-Version: 2026-03-10" || return 1 - test "${12}" = "-H" || return 1 - test "${13}" = "Authorization: Bearer fakejwt" || return 1 - test "${14}" = "https://api.something.ghe.com/orgs/an_org/installation" || return 1 - - echo '{"id": 123456}' - } - test $(get_github_app_install_id "$base_api_url" "$jwt" "$org" "$user" "$repo") = "123456" - unset curl -} - -it_gets_github_app_install_id_when_user_repo_set() { - local base_api_url="https://api.github.com" - local jwt="dummyjwt" - local org="" - local user="gh_user" - local repo="a-concourse-resource" - - curl() { - test "${5}" = "-s" || return 1 - test "${6}" = "-X" || return 1 - test "${7}" = "GET" || return 1 - test "${8}" = "-H" || return 1 - test "${9}" = "Accept: application/vnd.github+json" || return 1 - test "${10}" = "-H" || return 1 - test "${11}" = "X-GitHub-Api-Version: 2026-03-10" || return 1 - test "${12}" = "-H" || return 1 - test "${13}" = "Authorization: Bearer dummyjwt" || return 1 - test "${14}" = "https://api.github.com/repos/gh_user/a-concourse-resource/installation" || return 1 - - echo '{"id": 56421}' - } - test $(get_github_app_install_id "$base_api_url" "$jwt" "$org" "$user" "$repo") = "56421" - unset curl -} - -it_gets_github_app_access_token() { - local base_api_url="https://api.ourcompany.github.com" - local jwt="some-jwt" - local install_id="41234" - - curl() { - test "${5}" = "-s" || return 1 - test "${6}" = "-X" || return 1 - test "${7}" = "POST" || return 1 - test "${8}" = "-H" || return 1 - test "${9}" = "Accept: application/vnd.github+json" || return 1 - test "${10}" = "-H" || return 1 - test "${11}" = "X-GitHub-Api-Version: 2026-03-10" || return 1 - test "${12}" = "-H" || return 1 - test "${13}" = "Authorization: Bearer some-jwt" || return 1 - test "${14}" = "https://api.ourcompany.github.com/app/installations/41234/access_tokens" || return 1 - - echo '{"token": "mytoken"}' - } - test $(get_github_app_access_token "$base_api_url" "$jwt" "$install_id") = "mytoken" - unset curl -} - -it_fails_when_github_app_has_invalid_private_key() { - local input="{ - \"source\": { - \"uri\": \"https://fakecompany.ghe.com/concourse/git-resource\", - \"github_app_id\": \"56789\", - \"github_app_private_key\": \"garbage key\", - \"github_app_org\": \"some-org\" - } - }" - local err_code=0 - - setup_github_app_credentials "${input}" || { - err_code=1 - } - - test $err_code = 1 -} - -it_has_no_credential_helper_when_github_app_not_configured() { - local input="{ - \"source\": { - \"uri\": \"https://github.com/some-user/some-repo\" - } - }" - - setup_github_app_credentials "${input}" - - test -z "$(git config get --global credential.https://github.com.helper || true)" -} - -it_has_no_credential_helper_when_github_app_missing_private_key() { - local input="{ - \"source\": { - \"uri\": \"https://github.com/some-user/some-repo\", - \"github_app_id\": \"56789\", - \"github_app_user\": \"my-user\", - \"github_app_repo\": \"my-repo\" - } - }" - - setup_github_app_credentials "${input}" - - test -z "$(git config get --global credential.https://github.com.helper || true)" -} - -it_has_no_credential_helper_when_github_app_missing_app_id() { - local input="{ - \"source\": { - \"uri\": \"https://github.com/some-user/some-repo\", - \"github_app_private_key\": $(get_github_app_private_key_json), - \"github_app_user\": \"my-user\" - } - }" - - setup_github_app_credentials "${input}" - - test -z "$(git config get --global credential.https://github.com.helper || true)" -} - -it_has_no_credential_helper_when_github_app_missing_target() { - local input="{ - \"source\": { - \"uri\": \"https://github.com/some-user/some-repo\", - \"github_app_id\": \"99999\", - \"github_app_private_key\": $(get_github_app_private_key_json) - } - }" - - setup_github_app_credentials "${input}" - - test -z "$(git config get --global credential.https://github.com.helper || true)" -} - -it_sets_credential_helper_for_org_github_app() { - local input="{ - \"source\": { - \"uri\": \"https://fakecompany.ghe.com/concourse/git-resource\", - \"github_app_id\": \"56789\", - \"github_app_private_key\": $(get_github_app_private_key_json), - \"github_app_org\": \"some-org\" - } - }" - - create_github_app_jwt() { - local client_id=$1 - - test "$client_id" = "56789" || return 1 - - echo "test-jwt" - } - - get_github_app_install_id() { - local base_api_url=$1 - local jwt=$2 - local org=$3 - local user=$4 - local repo=$5 - - test "$base_api_url" = "https://api.fakecompany.ghe.com" || return 1 - test "$jwt" = "test-jwt" || return 1 - test "$org" = "some-org" || return 1 - test -z "${user}" || return 1 - test -z "${repo}" || return 1 - - echo "95432" - } - - get_github_app_access_token() { - local base_api_url=$1 - local jwt=$2 - local install_id=$3 - - test "$base_api_url" = "https://api.fakecompany.ghe.com" || return 1 - test "$jwt" = "test-jwt" || return 1 - test "$install_id" = "95432" || return 1 - - echo "a-token" - } - - export -f create_github_app_jwt get_github_app_install_id get_github_app_access_token - setup_github_app_credentials "${input}" - - test "$(git config get --global credential.https://fakecompany.ghe.com.helper)" = "!f() { echo \"username=x-access-token\"; echo \"password=a-token\"; }; f" - - # clean up tests - unset create_github_app_jwt get_github_app_install_id get_github_app_access_token - git config unset --global credential.https://fakecompany.ghe.com.helper -} - -it_sets_credential_helper_for_user_github_app() { - local input="{ - \"source\": { - \"uri\": \"https://github.com/test-user/test-repo\", - \"github_app_id\": \"99999\", - \"github_app_private_key\": $(get_github_app_private_key_json), - \"github_app_user\": \"the-user\" - } - }" - - create_github_app_jwt() { - local client_id=$1 - - test "$client_id" = "99999" || return 1 - - echo "test-jwt2" - } - - get_github_app_install_id() { - local base_api_url=$1 - local jwt=$2 - local org=$3 - local user=$4 - local repo=$5 - - test "$base_api_url" = "https://api.github.com" || return 1 - test "$jwt" = "test-jwt2" || return 1 - test -z "$org" || return 1 - test "$user" = "the-user" || return 1 - test -z "$repo" || return 1 - - echo "555555" - } - - get_github_app_access_token() { - local base_api_url=$1 - local jwt=$2 - local install_id=$3 - - test "$base_api_url" = "https://api.github.com" || return 1 - test "$jwt" = "test-jwt2" || return 1 - test "$install_id" = "555555" || return 1 - - echo "a-token2" - } - - export -f create_github_app_jwt get_github_app_install_id get_github_app_access_token - setup_github_app_credentials "${input}" - - test "$(git config get --global credential.https://github.com.helper)" = "!f() { echo \"username=x-access-token\"; echo \"password=a-token2\"; }; f" - - # clean up tests - unset create_github_app_jwt get_github_app_install_id get_github_app_access_token - git config unset --global credential.https://github.com.helper -} - -it_sets_credential_helper_for_repo_github_app() { - local input="{ - \"source\": { - \"uri\": \"https://mycompany.ghe.com/test-user/test-repo\", - \"github_app_id\": \"90210\", - \"github_app_private_key\": $(get_github_app_private_key_json), - \"github_app_user\": \"the-user\", - \"github_app_repo\": \"the-repo\" - } - }" - - create_github_app_jwt() { - local client_id=$1 - - test "$client_id" = "90210" || return 1 - - echo "test-jwt3" - } - - get_github_app_install_id() { - local base_api_url=$1 - local jwt=$2 - local org=$3 - local user=$4 - local repo=$5 - - test "$base_api_url" = "https://api.mycompany.ghe.com" || return 1 - test "$jwt" = "test-jwt3" || return 1 - test -z "$org" || return 1 - test "$user" = "the-user" || return 1 - test "$repo" = "the-repo" || return 1 - - echo "111111" - } - - get_github_app_access_token() { - local base_api_url=$1 - local jwt=$2 - local install_id=$3 - - test "$base_api_url" = "https://api.mycompany.ghe.com" || return 1 - test "$jwt" = "test-jwt3" || return 1 - test "$install_id" = "111111" || return 1 - - echo "a-token3" - } - - export -f create_github_app_jwt get_github_app_install_id get_github_app_access_token - setup_github_app_credentials "${input}" - - test "$(git config get --global credential.https://mycompany.ghe.com.helper)" = "!f() { echo \"username=x-access-token\"; echo \"password=a-token3\"; }; f" - - # clean up tests - unset create_github_app_jwt get_github_app_install_id get_github_app_access_token - git config unset --global credential.https://mycompany.ghe.com.helper -} - -run it_has_no_url_in_metadata_when_remote_is_not_configured -run it_has_no_url_in_metadata_when_remote_is_not_known - -run it_has_url_in_metadata_when_remote_is_github_scp -run it_has_url_in_metadata_when_remote_is_github_ssh -run it_has_url_in_metadata_when_remote_is_github_ssh_over_443 -run it_has_url_in_metadata_when_remote_is_github_https -run it_has_url_in_metadata_when_remote_is_likely_github_enterprise - -run it_has_url_in_metadata_when_remote_is_gitlab -run it_has_url_in_metadata_when_remote_is_bitbucket -run it_truncates_large_messages - -run it_creates_github_app_jwt -run it_gets_github_app_install_id_when_user_set -run it_gets_github_app_install_id_when_org_set -run it_gets_github_app_install_id_when_user_repo_set -run it_gets_github_app_access_token -run it_fails_when_github_app_has_invalid_private_key -run it_has_no_credential_helper_when_github_app_not_configured -run it_has_no_credential_helper_when_github_app_missing_private_key -run it_has_no_credential_helper_when_github_app_missing_app_id -run it_has_no_credential_helper_when_github_app_missing_target -run it_sets_credential_helper_for_org_github_app -run it_sets_credential_helper_for_user_github_app -run it_sets_credential_helper_for_repo_github_app diff --git a/test/get.sh b/test/get.sh deleted file mode 100755 index 331a0b1c..00000000 --- a/test/get.sh +++ /dev/null @@ -1,1181 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -it_can_get_from_url() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - get_uri $repo $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref -} - -it_can_get_from_url_at_ref() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit $repo) - - local dest=$TMPDIR/destination - - get_uri_at_ref $repo $ref1 $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref1 - - rm -rf $dest - - get_uri_at_ref $repo $ref2 $dest | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref2 -} - -it_can_get_from_url_at_branch() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_commit_to_branch $repo branch-b) - - local dest=$TMPDIR/destination - - get_uri_at_branch $repo "branch-a" $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref1 - - rm -rf $dest - - get_uri_at_branch $repo "branch-b" $dest | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref2 -} - -it_can_fetch_branches_that_already_exist() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo master) - - local dest=$TMPDIR/destination - - get_uri_with_fetch_branches $repo "master" $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " -} - -it_can_get_from_url_only_single_branch() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - get_uri_with_branch $repo "master" $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - ! git -C $dest rev-parse origin/bogus -} - -it_can_get_from_url_at_override_branch() { - local repo=$(init_repo) - local branch="branch-a" - local ref=$(make_commit_to_branch $repo $branch) - local dest=$TMPDIR/destination - - get_uri_with_override_branch $repo $branch $ref $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref -} - -it_can_get_from_url_with_all_branches() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - get_uri_with_all_branches $repo "master" $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - git -C $dest show-ref --verify refs/remotes/origin/master - git -C $dest show-ref --verify refs/remotes/origin/bogus -} - -it_preserves_git_config_in_local_repository() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - # Save original gitconfig and set up minimal config for the test - cp ~/.gitconfig ~/.gitconfig.bak 2>/dev/null || true - cat > ~/.gitconfig </dev/null || true -} - -it_can_get_from_url_with_sparse_paths() { - local repo=$(init_repo) - local ref1=$(make_commit_to_file $repo file-a) - local ref2=$(make_commit_to_file $repo file-b) - local dest=$TMPDIR/destination - local sparse_paths="file-a" - - get_uri_with_sparse $repo $dest $sparse_paths | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - - test -e $dest/file-a - test ! -e $dest/file-b - - test "$(git -C $dest rev-parse HEAD)" = $ref2 -} - -it_omits_empty_branch_in_metadata() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_commit_to_branch $repo branch-a) - local ref3=$(make_commit_to_branch $repo branch-a) - local ref4=$(make_commit $repo) - - local dest=$TMPDIR/destination - - get_uri_at_ref $repo $ref2 $dest | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - and - ([.metadata | .[] | select(.name == \"branch\")] == []) - " -} - -it_returns_branch_in_metadata() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_commit $repo) - - local dest=$TMPDIR/destination - - get_uri_at_branch $repo branch-a $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - and - (.metadata | .[] | select(.name == \"branch\") | .value == $(echo branch-a | jq -R .)) - " - - rm -rf $dest - - get_uri_at_ref $repo $ref2 $dest | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - and - (.metadata | .[] | select(.name == \"branch\") | .value == $(echo master | jq -R .)) - " -} - -it_omits_empty_tags_in_metadata() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - - local dest=$TMPDIR/destination - - get_uri_at_branch $repo branch-a $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - and - ([.metadata | .[] | select(.name == \"tags\")] == []) - " -} - -it_returns_list_of_tags_in_metadata() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - - git -C $repo tag v1.1-pre - git -C $repo tag v1.1-final - - local dest=$TMPDIR/destination - - get_uri_at_branch $repo branch-a $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - and - (.metadata | .[] | select(.name == \"tags\") | .value == \"v1.1-final,v1.1-pre\") - " -} - -it_writes_complete_metadata_files() { - local repo=$(init_repo) - - # Create a commit with specific author/committer info - git -C $repo \ - -c user.name='alice' \ - -c user.email='alice@example.com' \ - commit --allow-empty -m "test commit message" - local ref=$(git -C $repo rev-parse HEAD) - - # Add multiple tags to test tag aggregation - git -C $repo tag v1.0.0 - git -C $repo tag v1.0.0-rc1 - git -C $repo tag latest - - local dest=$TMPDIR/destination - get_uri $repo $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # === Verify metadata.json === - test -e $dest/.git/metadata.json || \ - ( echo ".git/metadata.json does not exist"; return 1 ) - - cat $dest/.git/metadata.json | jq -e '. | length > 0' > /dev/null || \ - ( echo ".git/metadata.json is not valid JSON or is empty"; return 1 ) - - # === Verify all metadata files === - - # .git/commit - test -e $dest/.git/commit || \ - ( echo ".git/commit does not exist"; return 1 ) - test "$(cat $dest/.git/commit)" = "$ref" || \ - ( echo ".git/commit content mismatch"; return 1 ) - - # .git/author - test -e $dest/.git/author || \ - ( echo ".git/author does not exist"; return 1 ) - test "$(cat $dest/.git/author)" = "alice" || \ - ( echo ".git/author content mismatch"; return 1 ) - - # .git/author_date - test -e $dest/.git/author_date || \ - ( echo ".git/author_date does not exist"; return 1 ) - echo "$(cat $dest/.git/author_date)" | grep -qE "^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [+-][0-9]{4}$" || \ - ( echo ".git/author_date format invalid: $(cat $dest/.git/author_date)"; return 1 ) - - # .git/committer - test -e $dest/.git/committer || \ - ( echo ".git/committer does not exist"; return 1 ) - test "$(cat $dest/.git/committer)" = "alice@example.com" || \ - ( echo ".git/committer content mismatch"; return 1 ) - - # .git/committer_name - test -e $dest/.git/committer_name || \ - ( echo ".git/committer_name does not exist"; return 1 ) - test "$(cat $dest/.git/committer_name)" = "alice" || \ - ( echo ".git/committer_name content mismatch"; return 1 ) - - # .git/committer_date - test -e $dest/.git/committer_date || \ - ( echo ".git/committer_date does not exist"; return 1 ) - echo "$(cat $dest/.git/committer_date)" | grep -qE "^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [+-][0-9]{4}$" || \ - ( echo ".git/committer_date format invalid"; return 1 ) - - # .git/ref - test -e $dest/.git/ref || \ - ( echo ".git/ref does not exist"; return 1 ) - test "$(cat $dest/.git/ref)" = "$ref" || \ - ( echo ".git/ref content mismatch"; return 1 ) - - # .git/branch - test -e $dest/.git/branch || \ - ( echo ".git/branch does not exist"; return 1 ) - test "$(cat $dest/.git/branch)" = "master" || \ - ( echo ".git/branch content mismatch"; return 1 ) - - # .git/short_ref - test -e $dest/.git/short_ref || \ - ( echo ".git/short_ref does not exist"; return 1 ) - local expected_short="test-$(echo $ref | cut -c1-7)" - test "$(cat $dest/.git/short_ref)" = "$expected_short" || \ - ( echo ".git/short_ref content mismatch"; return 1 ) - - # .git/commit_message - test -e $dest/.git/commit_message || \ - ( echo ".git/commit_message does not exist"; return 1 ) - grep -q "test commit message" $dest/.git/commit_message || \ - ( echo ".git/commit_message content mismatch"; return 1 ) - - # .git/commit_timestamp - test -e $dest/.git/commit_timestamp || \ - ( echo ".git/commit_timestamp does not exist"; return 1 ) - test -n "$(cat $dest/.git/commit_timestamp)" || \ - ( echo ".git/commit_timestamp is empty"; return 1 ) - - # .git/describe_ref - test -e $dest/.git/describe_ref || \ - ( echo ".git/describe_ref does not exist"; return 1 ) - - # .git/tags - test -e $dest/.git/tags || \ - ( echo ".git/tags does not exist"; return 1 ) - local tags=$(cat $dest/.git/tags) - test -n "$tags" || \ - ( echo ".git/tags is empty when tags exist"; return 1 ) - echo "$tags" | grep -q "v1.0.0" || \ - ( echo ".git/tags missing v1.0.0"; return 1 ) - echo "$tags" | grep -q "v1.0.0-rc1" || \ - ( echo ".git/tags missing v1.0.0-rc1"; return 1 ) - echo "$tags" | grep -q "latest" || \ - ( echo ".git/tags missing latest"; return 1 ) - - # .git/url - test -e $dest/.git/url || \ - ( echo ".git/url does not exist"; return 1 ) - test -z "$(cat $dest/.git/url)" || \ - ( echo ".git/url should be empty for local repo"; return 1 ) - - # === Test edge case: no tags === - rm -rf $dest - local repo_notags=$(init_repo) - local ref_notags=$(make_commit $repo_notags) - get_uri $repo_notags $dest - - test -e $dest/.git/tags || \ - ( echo ".git/tags does not exist when no tags present"; return 1 ) - test -z "$(cat $dest/.git/tags)" || \ - ( echo ".git/tags should be empty when no tags exist"; return 1 ) - - # === Verify metadata.json structure === - local has_commit=$(cat $dest/.git/metadata.json | jq '[.[] | select(.name == "commit")] | length') - test "$has_commit" = "1" || \ - ( echo "metadata.json missing commit field"; return 1 ) - - local has_author=$(cat $dest/.git/metadata.json | jq '[.[] | select(.name == "author")] | length') - test "$has_author" = "1" || \ - ( echo "metadata.json missing author field"; return 1 ) -} - -it_can_use_submodules_without_perl_warning() { - local repo=$(init_repo_with_submodule | cut -d "," -f1) - local dest=$TMPDIR/destination - - output=$(get_uri_with_submodules_all "file://"$repo 1 $dest 2>&1) - ! echo "${output}" | grep "perl: not found" -} - -it_honors_the_depth_flag() { - local repo=$(init_repo) - local firstCommitRef=$(make_commit $repo) - - make_commit $repo - - local lastCommitRef=$(make_commit $repo) - - local dest=$TMPDIR/destination - - get_uri_at_depth "file://"$repo 1 $dest | jq -e " - .version == {ref: $(echo $lastCommitRef | jq -R .)} - " - - test "$(git -C $dest rev-parse HEAD)" = $lastCommitRef - test "$(git -C $dest rev-list --all --count)" = 1 -} - -it_can_get_from_url_at_depth_at_ref() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit $repo) - - local dest=$TMPDIR/destination - - get_uri_at_depth_at_ref "file://$repo" 1 $ref1 $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref1 - - rm -rf $dest - - get_uri_at_depth_at_ref "file://$repo" 1 $ref2 $dest | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref2 -} - -it_falls_back_to_deep_clone_if_ref_not_found() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - - # 127 is the threshold when it starts doing a deep clone - for (( i = 0; i < 127; i++ )); do - make_commit $repo >/dev/null - done - - local dest=$TMPDIR/destination - - ( get_uri_at_depth_at_ref "file://$repo" 1 $ref1 $dest 3>&2- 2>&1- 1>&3- 3>&- | tee $TMPDIR/stderr ) 3>&1- 1>&2- 2>&3- 3>&- | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref1 - - echo "testing for msg 1" >&2 - for d in 1 3 7 15 31 63 127; do - grep "Could not find ref ${ref1}~0 in a shallow clone of depth ${d}" <$TMPDIR/stderr - done - echo "test for msg 1 done" >&2 - - for d in 2 4 8 16 32 64; do - grep "Deepening the shallow clone by an additional ${d}..." <$TMPDIR/stderr - done - - grep "Reached depth threshold 127, falling back to deep clone..." <$TMPDIR/stderr -} - -it_considers_depth_if_ref_not_found() { - local repo=$(init_repo) - local depth=3 - - # make commits we're interested - local ref0=$(make_commit $repo) - local ref1=$(make_commit $repo) - local ref2=$(make_commit $repo) - local ref3=$(make_commit $repo) - - # make a total of 22 commits, so that ref0 is never fetched - for (( i = 0; i < 18; i++ )); do - make_commit $repo >/dev/null - done - - local dest=$TMPDIR/destination - - ( get_uri_at_depth_at_ref "file://$repo" $depth $ref3 $dest 3>&2- 2>&1- 1>&3- 3>&- | tee $TMPDIR/stderr ) 3>&1- 1>&2- 2>&3- 3>&- | jq -e " - .version == {ref: $(echo $ref3 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref3 - test "$(git -C $dest rev-parse HEAD~1)" = $ref2 - test "$(git -C $dest rev-parse HEAD~2)" = $ref1 - test -e "$dest/.git/shallow" # it's still shallow - - echo "testing for 'could not find' messages'" >&2 - for d in 3 9; do - grep "Could not find ref ${ref3}~2 in a shallow clone of depth ${d}" <$TMPDIR/stderr - done - echo "testing for 'could not find' messages done" >&2 - - echo "testing for 'deepening' messages'" >&2 - for d in 6 12; do - grep "Deepening the shallow clone by an additional ${d}..." <$TMPDIR/stderr - done - echo "testing for 'deepening' messages' done" >&2 -} - -it_does_not_enter_an_infinite_loop_if_the_ref_cannot_be_found_and_depth_is_set() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=0123456789abcdef0123456789abcdef01234567 - - local dest=$TMPDIR/destination - - set +e - output=$(get_uri_at_depth_at_ref "file://$repo" 1 $ref2 $dest 2>&1) - exit_code=$? - set -e - - echo $output $exit_code - test "${exit_code}" = 128 - echo "${output}" | grep "Reached max depth of the origin repo while deepening the shallow clone, it's a deep clone now" - echo "${output}" | grep "fatal: unable to read tree (${ref2})" -} - -it_can_use_submodules_with_names_that_arent_paths() { - local repo_and_submodule=$(init_repo_with_named_submodule some-name some-path) - - local repo=$(echo $repo_and_submodule | cut -d, -f1) - local ref=$(make_commit $repo) - - local submodule=$(echo $repo_and_submodule | cut -d, -f2) - local submodule_ref=$(git -C $submodule rev-parse HEAD) - - local dest=$TMPDIR/destination - - get_uri_with_submodules_all "file://"$repo 1 $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - test "$(git -C $dest rev-parse HEAD)" = $ref - test "$(git -C $dest/some-path rev-parse HEAD)" = $submodule_ref -} - -it_can_use_submodules_with_missing_paths() { - local repo_and_submodule=$(init_repo_with_submodule_missing_path some-name some-path) - - local repo=$(echo $repo_and_submodule | cut -d, -f1) - local ref=$(make_commit $repo) - - local submodule=$(echo $repo_and_submodule | cut -d, -f2) - local submodule_ref=$(git -C $submodule rev-parse HEAD) - - local dest=$TMPDIR/destination - - get_uri_with_submodules_all "file://"$repo 1 $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - test "$(git -C $dest rev-parse HEAD)" = $ref - test ! -e $dest/some-path -} - -it_honors_the_depth_flag_for_submodules() { - local repo_with_submodule_info=$(init_repo_with_submodule) - local project_folder=$(echo $repo_with_submodule_info | cut -d "," -f1) - local submodule_folder=$(echo $repo_with_submodule_info | cut -d "," -f2) - local submodule_name=$(basename $submodule_folder) - local project_last_commit_id=$(git -C $project_folder rev-parse HEAD) - local submodule_last_commit_id=$(git -C $project_folder/$submodule_name rev-parse HEAD) - - local dest_all_depth0=$TMPDIR/destination_all_depth0 - - get_uri_with_submodules_all \ - "file://"$project_folder 0 $dest_all_depth0 | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - - test "$(git -C $dest_all_depth0 rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_all_depth0/$submodule_name rev-parse HEAD)" = $submodule_last_commit_id - test "$(git -C $dest_all_depth0/$submodule_name rev-list --all --count)" \> 1 - - local dest_one_depth0=$TMPDIR/destination_one_depth0 - - get_uri_with_submodules_at_depth \ - "file://"$project_folder 0 $submodule_name $dest_one_depth0 | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - - test "$(git -C $dest_one_depth0 rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_all_depth0/$submodule_name rev-parse HEAD)" = $submodule_last_commit_id - test "$(git -C $dest_one_depth0/$submodule_name rev-list --all --count)" \> 1 - - local dest_all_depth1=$TMPDIR/destination_all_depth1 - - get_uri_with_submodules_all \ - "file://"$project_folder 1 $dest_all_depth1 | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - - test "$(git -C $dest_all_depth1 rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_all_depth1/$submodule_name rev-parse HEAD)" = $submodule_last_commit_id - test "$(git -C $dest_all_depth1/$submodule_name rev-list --all --count)" = 1 - - local dest_one_depth1=$TMPDIR/destination_one_depth1 - - get_uri_with_submodules_at_depth \ - "file://"$project_folder 1 $submodule_name $dest_one_depth1 | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - - test "$(git -C $dest_one_depth1 rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_all_depth1/$submodule_name rev-parse HEAD)" = $submodule_last_commit_id - test "$(git -C $dest_one_depth1/$submodule_name rev-list --all --count)" = 1 -} - -it_falls_back_to_deep_clone_of_submodule_if_ref_not_found() { - local repo_with_submodule_info=$(init_repo_with_submodule) - local main_repo=${repo_with_submodule_info%,*} - local submodule_repo=${repo_with_submodule_info#*,} - local submodule_name=${submodule_repo##*/} - local main_repo_last_commit_id=$(git -C $main_repo rev-parse HEAD) - local submodule_repo_last_commit_id=$(git -C $submodule_repo rev-parse HEAD) - - # 127 is the threshold when it starts doing a deep clone - for (( i = 0; i < 127; i++ )); do - make_commit $submodule_repo >/dev/null - done - - local dest=$TMPDIR/destination - - ( \ - get_uri_with_submodules_all \ - "file://$main_repo" 1 $dest 3>&2- 2>&1- 1>&3- 3>&- \ - | tee $TMPDIR/stderr \ - ) 3>&1- 1>&2- 2>&3- 3>&- | jq -e " - .version == {ref: $(echo $main_repo_last_commit_id | jq -R .)} - " - - test "$(git -C $main_repo rev-parse HEAD)" = $main_repo_last_commit_id - - echo "testing for 'could not find' messages'" >&2 - for d in 1 3 7 15 31 63 127; do - grep "Could not find ref ${submodule_repo_last_commit_id}~0 in a shallow clone of depth ${d}" <$TMPDIR/stderr - done - echo "testing for 'could not find' messages done" >&2 - - echo "testing for 'deepening' messages'" >&2 - for d in 2 4 8 16 32 64; do - grep "Deepening the shallow clone by an additional ${d}..." <$TMPDIR/stderr - done - echo "testing for 'deepening' messages' done" >&2 - - echo "testing for 'reached threshold' message'" >&2 - grep "Reached depth threshold 127, falling back to deep clone..." <$TMPDIR/stderr - echo "testing for 'reached threshold' message done'" >&2 -} - -it_fails_if_the_ref_cannot_be_found_while_deepening_a_submodule() { - local repo_with_submodule_info=$(init_repo_with_submodule) - local main_repo=${repo_with_submodule_info%,*} - local submodule_repo=${repo_with_submodule_info#*,} - local submodule_name=${submodule_repo##*/} - local submodule_last_commit_id=$(git -C "$submodule_repo" rev-parse HEAD) - - git -C "$submodule_repo" reset --hard HEAD^ >/dev/null - - local dest=$TMPDIR/destination - - output=$(get_uri_with_submodules_all "file://$main_repo" 1 $dest 2>&1) \ - && exit_code=$? || exit_code=$? - - echo $output $exit_code - test "${exit_code}" \!= 0 - echo "${output}" | grep "Reached max depth of the origin repo while deepening the shallow clone, it's a deep clone now" - echo "${output}" | grep "fatal: unable to read tree (${submodule_last_commit_id})" -} - -it_honors_the_parameter_flags_for_submodules() { - local repo_info=$(init_repo_with_submodule_of_nested_submodule) - local project_folder=$(echo $repo_info | cut -d "," -f1) - local submodule_folder=$(echo $repo_info | cut -d "," -f2) - local submodule_name=$(basename $submodule_folder) - local subsubmodule_folder=$(echo $repo_info | cut -d "," -f3) - local subsubmodule_name=$(basename $subsubmodule_folder) - local project_last_commit_id=$(git -C $project_folder rev-parse HEAD) - - echo $project_folder - echo $submodule_name - echo $subsubmodule_name - - # testing: recursive explicit enabled - local dest_recursive_true=$TMPDIR/recursive_true - get_uri_with_submodules_and_parameter_recursive \ - "file://"$project_folder 1 "all" true $dest_recursive_true | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - test "$(git -C $project_folder rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_recursive_true/$submodule_name rev-list --all --count)" = 1 - test "$(git -C $dest_recursive_true/$submodule_name/$subsubmodule_name rev-list --all --count)" = 1 - - # recursive explicit disabled - local dest_recursive_false=$TMPDIR/recursive_false - get_uri_with_submodules_and_parameter_recursive \ - "file://"$project_folder 1 "all" false $dest_recursive_false | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - test "$(git -C $project_folder rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_recursive_false/$submodule_name rev-list --all --count)" = 1 - test "$(ls $dest_recursive_false/$submodule_name/$subsubmodule_name | wc -l)" = 0 - - # remote explicit enabled - local dest_remote_true=$TMPDIR/remote_true - get_uri_with_submodules_and_parameter_remote \ - "file://"$project_folder 1 "all" true $dest_remote_true | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - test "$(git -C $project_folder rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_remote_true/$submodule_name rev-list --all --count)" = 1 - test "$(git -C $dest_remote_true/$submodule_name/$subsubmodule_name rev-list --all --count)" = 1 - - # remote explicit disabled - local dest_remote_false=$TMPDIR/remote_false - get_uri_with_submodules_and_parameter_remote \ - "file://"$project_folder 1 "all" false $dest_remote_false | jq -e " - .version == {ref: $(echo $project_last_commit_id | jq -R .)} - " - test "$(git -C $project_folder rev-parse HEAD)" = $project_last_commit_id - test "$(git -C $dest_remote_false/$submodule_name rev-list --all --count)" = 1 - test "$(git -C $dest_remote_false/$submodule_name/$subsubmodule_name rev-list --all --count)" = 1 -} - -it_can_get_and_set_git_config() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - cp ~/.gitconfig ~/.gitconfig.orig - - get_uri_with_config $repo $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - test "$(git config --global core.pager)" == 'true' - test "$(git config --global credential.helper)" == '!true long command with variables $@' - - mv ~/.gitconfig.orig ~/.gitconfig -} - -it_returns_same_ref() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "other tag") - local ref3=$(make_annotated_tag $repo "0.9-production" "a tag") - local ref4=$(make_commit $repo) - local ref5=$(make_annotated_tag $repo "1.1-staging" "another tag") - local ref6=$(make_commit $repo) - - get_uri_at_ref $repo $ref1 $TMPDIR/destination | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " - rm -rf $TMPDIR/destination - get_uri_at_ref $repo $ref2 $TMPDIR/destination | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - rm -rf $TMPDIR/destination - get_uri_at_ref $repo $ref3 $TMPDIR/destination | jq -e " - .version == {ref: $(echo $ref3 | jq -R .)} - " -} - -it_cant_get_commit_with_invalid_key() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - set +e - output=$(get_uri_with_invalid_verification_key $repo $dest 2>&1) - exit_code=$? - set -e - - test "${exit_code}" == 2 - echo "${output}" | grep "Invalid GPG key in: abcd" -} - -it_cant_get_commit_not_signed() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - set +e - output=$(get_uri_with_verification_key $repo $dest 2>&1) - exit_code=$? - set -e - - test "${exit_code}" == 1 - echo "${output}" | grep "The commit ${ref} is not signed" -} - -it_can_get_signed_commit() { - local repo=$(gpg_fixture_repo_path) - local ref=$(fetch_head_ref $repo) - test "$ref" != "" - local dest=$TMPDIR/destination - - get_uri_with_verification_key $repo $dest - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref -} - -it_can_get_signed_commit_via_tag() { - local repo=$(gpg_fixture_repo_path) - local commit=$(fetch_head_ref $repo) - local ref=$(make_annotated_tag $repo 'test-0.0.1' 'a message') - local dest=$TMPDIR/destination - - get_uri_with_verification_key_and_tag_filter $repo $dest 'test-*' $ref - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $commit -} - -it_can_get_signed_commit_via_tag_regex() { - local repo=$(gpg_fixture_repo_path) - local commit=$(fetch_head_ref $repo) - local ref=$(make_annotated_tag $repo 'test2-0.0.1' 'a message') - local dest=$TMPDIR/destination - - get_uri_with_verification_key_and_tag_regex $repo $dest 'test2-.*' $ref - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $commit -} - -it_cant_get_commit_signed_with_unknown_key() { - local repo=$(gpg_fixture_repo_path) - local ref=$(fetch_head_ref $repo) - test "$ref" != "" - local dest=$TMPDIR/destination - - set +e - output=$(get_uri_with_unknown_verification_key $repo $dest 2>&1) - exit_code=$? - set -e - - test "${exit_code}" = 1 - echo "${output}" | grep "gpg: Can't check signature: No public key" -} - -it_cant_get_signed_commit_when_using_keyserver_and_bogus_key() { - local repo=$(gpg_fixture_repo_path) - local ref=$(fetch_head_ref $repo) - test "$ref" != "" - local dest=$TMPDIR/destination - - set +e - output=$(get_uri_when_using_keyserver_and_bogus_key $repo $dest 2>&1) - exit_code=$? - set -e - - test "${exit_code}" = 123 - echo "${output}" | grep "gpg: \"abcd\" not a key ID: skipping" -} - -it_cant_get_signed_commit_when_using_keyserver_and_unknown_key_id() { - local repo=$(gpg_fixture_repo_path) - local ref=$(fetch_head_ref $repo) - test "$ref" != "" - local dest=$TMPDIR/destination - - set +e - output=$(get_uri_when_using_keyserver_and_unknown_key $repo $dest 2>&1) - exit_code=$? - set -e - - echo $output $exit_code - test "${exit_code}" = 123 - echo "${output}" | grep "gpg: keyserver receive failed" # removed the "No data" because it would not consistently return that copy (network issues?) -} - -it_can_get_signed_commit_when_using_keyserver() { - local repo=$(gpg_fixture_repo_path) - local ref=$(fetch_head_ref $repo) - test "$ref" != "" - local dest=$TMPDIR/destination - - get_uri_when_using_keyserver $repo $dest - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref -} - -it_can_get_committer_email() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - local committer_email="test@example.com" - - get_uri $repo $dest | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - test -e $dest/.git/committer || \ - ( echo ".git/committer does not exist."; return 1 ) - test "$(cat $dest/.git/committer)" = $committer_email || \ - ( echo "Committer email not found."; return 1 ) -} - -it_can_get_returned_ref() { - local repo=$(init_repo) - local ref=$(make_commit $repo) - local dest=$TMPDIR/destination - - local repo=$(init_repo) - local ref1=$(make_commit $repo) - local ref2=$(make_annotated_tag $repo "1.0-staging" "other tag") - local ref3=$(make_annotated_tag $repo "0.9-production" "a tag") - local ref4=$(make_commit $repo) - local ref5=$(make_annotated_tag $repo "1.1-staging" "another tag") - local ref6=$(make_commit $repo) - - get_uri_at_ref $repo $ref1 $TMPDIR/destination | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - " - test -e $dest/.git/ref || ( echo ".git/ref does not exist."; return 1 ) - test "$(cat $dest/.git/ref)" = "${ref1}" || \ - ( echo ".git/ref does not match. Expected '${ref1}', got '$(cat $dest/.git/ref)'"; return 1 ) - - rm -rf $TMPDIR/destination - get_uri_at_ref $repo $ref2 $TMPDIR/destination | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - test -e $dest/.git/ref || ( echo ".git/ref does not exist."; return 1 ) - test "$(cat $dest/.git/ref)" = "${ref2}" || \ - ( echo ".git/ref does not match. Expected '${ref2}', got '$(cat $dest/.git/ref)'"; return 1 ) - - rm -rf $TMPDIR/destination - get_uri_at_ref $repo $ref3 $TMPDIR/destination | jq -e " - .version == {ref: $(echo $ref3 | jq -R .)} - " - test -e $dest/.git/ref || ( echo ".git/ref does not exist."; return 1 ) - test "$(cat $dest/.git/ref)" = "${ref3}" || \ - ( echo ".git/ref does not match. Expected '${ref3}', got '$(cat $dest/.git/ref)'"; return 1 ) - - test -e $dest/.git/short_ref || ( echo ".git/short_ref does not exist."; return 1 ) - local expected_short_ref="test-$(echo ${ref3} | cut -c1-7)" - test "$(cat $dest/.git/short_ref)" = $expected_short_ref || \ - ( echo ".git/short_ref does not match. Expected '${expected_short_ref}', got '$(cat $dest/.git/short_ref)'"; return 1 ) - - test -e $dest/.git/describe_ref || ( echo ".git/describe_ref does not exist."; return 1 ) - local expected_describe_ref="0.9-production" - test "$(cat $dest/.git/describe_ref)" = $expected_describe_ref || \ - ( echo ".git/describe_ref does not match. Expected '${expected_describe_ref}', got '$(cat $dest/.git/describe_ref)'"; return 1 ) -} - -it_can_get_commit_branch() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_commit $repo) - local ref3=$(make_annotated_tag $repo "v1.1" "tag 1") - - local dest=$TMPDIR/destination - - get_uri $repo $dest - - test -e $dest/.git/branch || ( echo ".git/branch does not exist."; return 1 ) - test "$(cat $dest/.git/branch)" = "master" || \ - ( echo ".git/branch does not match. Expected 'master', got '$(cat $dest/.git/branch)'"; return 1 ) - - rm -rf $dest - - get_uri_at_branch $repo branch-a $dest - - test -e $dest/.git/branch || ( echo ".git/branch does not exist."; return 1 ) - test "$(cat $dest/.git/branch)" = "branch-a" || \ - ( echo ".git/branch does not match. Expected 'branch-a', got '$(cat $dest/.git/branch)'"; return 1 ) -} - -it_can_get_commit_message() { - local repo=$(init_repo) - local commit_message='Awesome-commit-message' - local ref=$(make_commit $repo $commit_message) - local dest=$TMPDIR/destination - local expected_content="commit 1 $repo/some-file $commit_message" - - get_uri $repo $dest - - test -e $dest/.git/commit_message || \ - ( echo ".git/commit_message does not exist."; return 1 ) - test "$(cat $dest/.git/commit_message)" = "$expected_content" || \ - ( echo "Commit message does not match."; return 1 ) -} - -it_can_get_commit_timestamps() { - run test_commit_timestamp_format "iso8601" - run test_commit_timestamp_format "iso-strict" - run test_commit_timestamp_format "rfc" - run test_commit_timestamp_format "short" - run test_commit_timestamp_format "raw" - run test_commit_timestamp_format "unix" -} - -test_commit_timestamp_format() { - local repo=$(init_repo) - local commit_message='Time-is-relevant!' - local ref=$(make_commit $repo $commit_message) - local dest=$TMPDIR/destination - - get_uri_with_custom_timestamp $repo $dest $1 - - pushd $dest - local expected_timestamp=$(git log -1 --date=$1 --format=format:%cd) - popd - - test -e $dest/.git/commit_timestamp || ( echo ".git/commit_timestamp does not exist."; return 1 ) - test "$(cat $dest/.git/commit_timestamp)" = "$expected_timestamp" || \ - ( echo "Commit timestamp for format $1 differs from expectation."; return 1 ) -} - -it_decrypts_git_crypted_files() { - local repo=$(git_crypt_fixture_repo_path) - local dest=$TMPDIR/destination - - get_uri_with_git_crypt_key $repo $dest - - test $(cat $dest/secrets.txt) = "secret" || \ - ( echo "encrypted file was not decrypted"; return 1 ) -} - -it_clears_tags_with_clean_tags_param() { - local repo=$(init_repo) - local ref1=$(make_commit $repo) - git -C $repo tag v1.1-pre - - local dest=$TMPDIR/destination - - get_uri_with_clean_tags $repo $dest "true" - - test -z "$(git -C $dest tag)" -} - -it_retains_tags_by_default() { - local tag="v1.1-pre" - local repo=$(init_repo) - local ref1=$(make_commit $repo) - git -C $repo tag $tag - - local dest=$TMPDIR/destination - - get_uri $repo $dest - - test "$(git -C $dest tag)" == $tag -} - -it_retains_tags_with_clean_tags_param() { - local tag="v1.1-pre" - local repo=$(init_repo) - local ref1=$(make_commit $repo) - git -C $repo tag $tag - - local dest=$TMPDIR/destination - - get_uri_with_clean_tags $repo $dest "false" - - test "$(git -C $dest tag)" == $tag -} - -it_returns_list_without_tags_in_metadata() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - - local ref2=$(make_annotated_tag $repo "v1.1-pre" "tag 1") - local ref3=$(make_annotated_tag $repo "v1.1-final" "tag 2") - - local dest=$TMPDIR/destination - get_uri_at_branch_without_fetch_tags $repo branch-a $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - and - (.metadata | .[] | select(.name != \"tags\")) - " -} - -it_returns_list_of_all_tags_in_metadata() { - - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_annotated_tag $repo "v1.1-pre" "tag 1") - local ref3=$(make_annotated_tag $repo "v1.1-final" "tag 2") - local ref4=$(make_annotated_tag $repo "v1.1-branch-b" "tag 3") - - local dest=$TMPDIR/destination - get_uri_at_branch_with_fetch_tags $repo branch-a $dest | jq -e " - .version == {ref: $(echo $ref1 | jq -R .)} - and - (.metadata | .[] | select(.name == \"tags\") | .value == \"v1.1-branch-b,v1.1-final,v1.1-pre\") - " -} - -it_can_get_from_url_at_branch_with_search_remote_refs() { - local repo=$(init_repo) - local ref1=$(make_commit_to_branch $repo branch-a) - local ref2=$(make_commit_to_branch $repo branch-a) - git -C $repo update-ref refs/heads/branch-a $ref1 - git -C $repo update-ref refs/changes/1 $ref2 - git -C $repo log --all --oneline - git -C $repo branch -v - local dest=$TMPDIR/destination - - # use file:// repo to force the regular git transport instead of local copying - set +e - output=$(get_uri_at_branch_with_ref file://$repo "branch-a" $ref2 $dest 2>&1) - exit_code=$? - set -e - - echo $output $exit_code - test "${exit_code}" = 128 - echo "$output" | grep "fatal: unable to read tree (" - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" != $ref2 - - rm -rf $dest - - get_uri_at_branch_with_search_remote_refs file://$repo "branch-a" $ref2 $dest | jq -e " - .version == {ref: $(echo $ref2 | jq -R .)} - " - - test -e $dest/some-file - test "$(git -C $dest rev-parse HEAD)" = $ref2 -} - -it_errors_when_there_are_unknown_keys_in_params() { - local failed_output=$TMPDIR/get-unknown-keys-output - if get_uri_unknown_keys "some-uri" "some-dest" 2>"$failed_output"; then - echo "get should have failed" - return 1 - fi - - grep "Found unknown keys in get params:" "$failed_output" - grep "unknown_key" "$failed_output" - grep "other_key" "$failed_output" -} - -run it_can_use_submodules_with_missing_paths -run it_can_use_submodules_with_names_that_arent_paths -run it_can_use_submodules_without_perl_warning -run it_honors_the_depth_flag_for_submodules -run it_falls_back_to_deep_clone_of_submodule_if_ref_not_found -run it_fails_if_the_ref_cannot_be_found_while_deepening_a_submodule -run it_honors_the_parameter_flags_for_submodules -run it_can_fetch_branches_that_already_exist -run it_can_get_from_url -run it_can_get_from_url_at_ref -run it_can_get_from_url_at_branch -run it_can_get_from_url_only_single_branch -run it_can_get_from_url_at_override_branch -run it_can_get_from_url_with_all_branches -run it_preserves_git_config_in_local_repository -run it_can_get_from_url_with_sparse_paths -run it_omits_empty_branch_in_metadata -run it_returns_branch_in_metadata -run it_omits_empty_tags_in_metadata -run it_returns_list_of_tags_in_metadata -run it_writes_complete_metadata_files -run it_honors_the_depth_flag -run it_can_get_from_url_at_depth_at_ref -run it_falls_back_to_deep_clone_if_ref_not_found -run it_considers_depth_if_ref_not_found -run it_does_not_enter_an_infinite_loop_if_the_ref_cannot_be_found_and_depth_is_set -run it_can_get_and_set_git_config -run it_returns_same_ref -run it_cant_get_commit_with_invalid_key -run it_cant_get_commit_not_signed -run it_can_get_signed_commit -run it_cant_get_commit_signed_with_unknown_key -run it_cant_get_signed_commit_when_using_keyserver_and_bogus_key -run it_cant_get_signed_commit_when_using_keyserver_and_unknown_key_id -run it_can_get_signed_commit_when_using_keyserver -run it_can_get_signed_commit_via_tag -run it_can_get_signed_commit_via_tag_regex -run it_can_get_committer_email -run it_can_get_returned_ref -run it_can_get_commit_branch -run it_can_get_commit_message -run it_can_get_commit_timestamps -run it_decrypts_git_crypted_files -run it_clears_tags_with_clean_tags_param -run it_retains_tags_by_default -run it_retains_tags_with_clean_tags_param -run it_returns_list_without_tags_in_metadata -run it_returns_list_of_all_tags_in_metadata -run it_can_get_from_url_at_branch_with_search_remote_refs -run it_errors_when_there_are_unknown_keys_in_params diff --git a/test/get_branches.sh b/test/get_branches.sh deleted file mode 100755 index b982d2d3..00000000 --- a/test/get_branches.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -it_saves_the_given_branches() { - local dest=$TMPDIR/destination - mkdir -p $dest - - get_branches "some-uri" "feat/foo,feat/bar,issue/qwerty" $dest | jq -e ' - .version.branches == "feat/foo,feat/bar,issue/qwerty" - ' - - jq -e '. == ["feat/foo","feat/bar","issue/qwerty"]' < $dest/branches.json -} - -it_saves_a_single_branch() { - local dest=$TMPDIR/destination - mkdir -p $dest - - get_branches "some-uri" "feat/foo" $dest | jq -e ' - .version.branches == "feat/foo" - ' - - jq -e '. == ["feat/foo"]' < $dest/branches.json -} - -it_saves_empty_array_when_version_is_none() { - local dest=$TMPDIR/destination - mkdir -p $dest - - get_branches "some-uri" "NONE" $dest - - jq -e '. == []' < $dest/branches.json -} - -it_saves_metadata_as_multiline_string() { - local dest=$TMPDIR/destination - mkdir -p $dest - - get_branches "some-uri" "feat/foo,feat/bar,issue/qwerty" $dest | jq -e ' - (.metadata[] | select(.name == "branches") | .value) == "feat/foo\nfeat/bar\nissue/qwerty" - ' -} - -run it_saves_the_given_branches -run it_saves_a_single_branch -run it_saves_empty_array_when_version_is_none -run it_saves_metadata_as_multiline_string diff --git a/test/get_tags.sh b/test/get_tags.sh deleted file mode 100755 index 5ee3f010..00000000 --- a/test/get_tags.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -it_clones_the_repo_at_the_given_tag() { - local repo=$(init_repo) - make_commit $repo >/dev/null - make_annotated_tag $repo v1 "tag v1" >/dev/null - local tag_ref=$(git -C $repo rev-parse v1^{commit}) - - local dest=$TMPDIR/destination - - get_tags $repo v1 $dest | jq -e '.version.tag == "v1"' - - ! git -C $dest symbolic-ref -q HEAD - - test "$(git -C $dest rev-parse HEAD)" = "$tag_ref" -} - -it_saves_the_tag_metadata() { - local repo=$(init_repo) - make_commit $repo >/dev/null - make_annotated_tag $repo v1 "tag v1" >/dev/null - - local dest=$TMPDIR/destination - - get_tags $repo v1 $dest - - jq -e 'any(.name == "tag" and .value == "v1")' < $dest/.git/metadata.json -} - -run it_clones_the_repo_at_the_given_tag -run it_saves_the_tag_metadata diff --git a/test/git-crypt/fixture_repo.git/HEAD b/test/git-crypt/fixture_repo.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/test/git-crypt/fixture_repo.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/git-crypt/fixture_repo.git/config b/test/git-crypt/fixture_repo.git/config deleted file mode 100644 index e6da2315..00000000 --- a/test/git-crypt/fixture_repo.git/config +++ /dev/null @@ -1,6 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = true - ignorecase = true - precomposeunicode = true diff --git a/test/git-crypt/fixture_repo.git/description b/test/git-crypt/fixture_repo.git/description deleted file mode 100644 index 498b267a..00000000 --- a/test/git-crypt/fixture_repo.git/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/git-crypt/fixture_repo.git/hooks/applypatch-msg.sample b/test/git-crypt/fixture_repo.git/hooks/applypatch-msg.sample deleted file mode 100755 index a5d7b84a..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/applypatch-msg.sample +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -commitmsg="$(git rev-parse --git-path hooks/commit-msg)" -test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} -: diff --git a/test/git-crypt/fixture_repo.git/hooks/commit-msg.sample b/test/git-crypt/fixture_repo.git/hooks/commit-msg.sample deleted file mode 100755 index b58d1184..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/commit-msg.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/test/git-crypt/fixture_repo.git/hooks/post-update.sample b/test/git-crypt/fixture_repo.git/hooks/post-update.sample deleted file mode 100755 index ec17ec19..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/test/git-crypt/fixture_repo.git/hooks/pre-applypatch.sample b/test/git-crypt/fixture_repo.git/hooks/pre-applypatch.sample deleted file mode 100755 index 4142082b..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/test/git-crypt/fixture_repo.git/hooks/pre-commit.sample b/test/git-crypt/fixture_repo.git/hooks/pre-commit.sample deleted file mode 100755 index 68d62d54..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/test/git-crypt/fixture_repo.git/hooks/pre-push.sample b/test/git-crypt/fixture_repo.git/hooks/pre-push.sample deleted file mode 100755 index 6187dbf4..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -z40=0000000000000000000000000000000000000000 - -while read local_ref local_sha remote_ref remote_sha -do - if [ "$local_sha" = $z40 ] - then - # Handle delete - : - else - if [ "$remote_sha" = $z40 ] - then - # New branch, examine all commits - range="$local_sha" - else - # Update to existing branch, examine new commits - range="$remote_sha..$local_sha" - fi - - # Check for WIP commit - commit=`git rev-list -n 1 --grep '^WIP' "$range"` - if [ -n "$commit" ] - then - echo >&2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/test/git-crypt/fixture_repo.git/hooks/pre-rebase.sample b/test/git-crypt/fixture_repo.git/hooks/pre-rebase.sample deleted file mode 100755 index 33730ca6..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up-to-date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -<<\DOC_END - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". - -DOC_END diff --git a/test/git-crypt/fixture_repo.git/hooks/pre-receive.sample b/test/git-crypt/fixture_repo.git/hooks/pre-receive.sample deleted file mode 100755 index a1fd29ec..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/pre-receive.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to make use of push options. -# The example simply echoes all push options that start with 'echoback=' -# and rejects all pushes when the "reject" push option is used. -# -# To enable this hook, rename this file to "pre-receive". - -if test -n "$GIT_PUSH_OPTION_COUNT" -then - i=0 - while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" - do - eval "value=\$GIT_PUSH_OPTION_$i" - case "$value" in - echoback=*) - echo "echo from the pre-receive-hook: ${value#*=}" >&2 - ;; - reject) - exit 1 - esac - i=$((i + 1)) - done -fi diff --git a/test/git-crypt/fixture_repo.git/hooks/prepare-commit-msg.sample b/test/git-crypt/fixture_repo.git/hooks/prepare-commit-msg.sample deleted file mode 100755 index f093a02e..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first comments out the -# "Conflicts:" part of a merge commit. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -case "$2,$3" in - merge,) - /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; - -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$1" ;; - - *) ;; -esac - -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/test/git-crypt/fixture_repo.git/hooks/update.sample b/test/git-crypt/fixture_repo.git/hooks/update.sample deleted file mode 100755 index 80ba9413..00000000 --- a/test/git-crypt/fixture_repo.git/hooks/update.sample +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -# -# An example hook script to block unannotated tags from entering. -# Called by "git receive-pack" with arguments: refname sha1-old sha1-new -# -# To enable this hook, rename this file to "update". -# -# Config -# ------ -# hooks.allowunannotated -# This boolean sets whether unannotated tags will be allowed into the -# repository. By default they won't be. -# hooks.allowdeletetag -# This boolean sets whether deleting tags will be allowed in the -# repository. By default they won't be. -# hooks.allowmodifytag -# This boolean sets whether a tag may be modified after creation. By default -# it won't be. -# hooks.allowdeletebranch -# This boolean sets whether deleting branches will be allowed in the -# repository. By default they won't be. -# hooks.denycreatebranch -# This boolean sets whether remotely creating branches will be denied -# in the repository. By default this is allowed. -# - -# --- Command line -refname="$1" -oldrev="$2" -newrev="$3" - -# --- Safety check -if [ -z "$GIT_DIR" ]; then - echo "Don't run this script from the command line." >&2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --bool hooks.allowunannotated) -allowdeletebranch=$(git config --bool hooks.allowdeletebranch) -denycreatebranch=$(git config --bool hooks.denycreatebranch) -allowdeletetag=$(git config --bool hooks.allowdeletetag) -allowmodifytag=$(git config --bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero="0000000000000000000000000000000000000000" -if [ "$newrev" = "$zero" ]; then - newrev_type=delete -else - newrev_type=$(git cat-file -t $newrev) -fi - -case "$refname","$newrev_type" in - refs/tags/*,commit) - # un-annotated tag - short_refname=${refname##refs/tags/} - if [ "$allowunannotated" != "true" ]; then - echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 diff --git a/test/git-crypt/fixture_repo.git/info/exclude b/test/git-crypt/fixture_repo.git/info/exclude deleted file mode 100644 index a5196d1b..00000000 --- a/test/git-crypt/fixture_repo.git/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff --git a/test/git-crypt/fixture_repo.git/objects/24/8f712755733ef97619e4f226fc139fc89a2f07 b/test/git-crypt/fixture_repo.git/objects/24/8f712755733ef97619e4f226fc139fc89a2f07 deleted file mode 100644 index 2d14d44b..00000000 Binary files a/test/git-crypt/fixture_repo.git/objects/24/8f712755733ef97619e4f226fc139fc89a2f07 and /dev/null differ diff --git a/test/git-crypt/fixture_repo.git/objects/87/6caedf3e7fd2a9289ae6d952efa93725f6531b b/test/git-crypt/fixture_repo.git/objects/87/6caedf3e7fd2a9289ae6d952efa93725f6531b deleted file mode 100644 index b1de4271..00000000 Binary files a/test/git-crypt/fixture_repo.git/objects/87/6caedf3e7fd2a9289ae6d952efa93725f6531b and /dev/null differ diff --git a/test/git-crypt/fixture_repo.git/objects/b5/ef7cf607d0cf5ec2ca04fa1b08e1059e270c82 b/test/git-crypt/fixture_repo.git/objects/b5/ef7cf607d0cf5ec2ca04fa1b08e1059e270c82 deleted file mode 100644 index 72012d68..00000000 Binary files a/test/git-crypt/fixture_repo.git/objects/b5/ef7cf607d0cf5ec2ca04fa1b08e1059e270c82 and /dev/null differ diff --git a/test/git-crypt/fixture_repo.git/objects/d6/96f5b678db93c18c06d33fd973186257f9c0b7 b/test/git-crypt/fixture_repo.git/objects/d6/96f5b678db93c18c06d33fd973186257f9c0b7 deleted file mode 100644 index ca34e048..00000000 Binary files a/test/git-crypt/fixture_repo.git/objects/d6/96f5b678db93c18c06d33fd973186257f9c0b7 and /dev/null differ diff --git a/test/git-crypt/fixture_repo.git/refs/heads/master b/test/git-crypt/fixture_repo.git/refs/heads/master deleted file mode 100644 index ea8404c4..00000000 --- a/test/git-crypt/fixture_repo.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -b5ef7cf607d0cf5ec2ca04fa1b08e1059e270c82 diff --git a/test/git-crypt/fixture_repo.key b/test/git-crypt/fixture_repo.key deleted file mode 100644 index 131e2629..00000000 Binary files a/test/git-crypt/fixture_repo.key and /dev/null differ diff --git a/test/gpg/fixture_repo.git/HEAD b/test/gpg/fixture_repo.git/HEAD deleted file mode 100644 index cb089cd8..00000000 --- a/test/gpg/fixture_repo.git/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/gpg/fixture_repo.git/config b/test/gpg/fixture_repo.git/config deleted file mode 100644 index e6da2315..00000000 --- a/test/gpg/fixture_repo.git/config +++ /dev/null @@ -1,6 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = true - ignorecase = true - precomposeunicode = true diff --git a/test/gpg/fixture_repo.git/description b/test/gpg/fixture_repo.git/description deleted file mode 100644 index 498b267a..00000000 --- a/test/gpg/fixture_repo.git/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/gpg/fixture_repo.git/info/exclude b/test/gpg/fixture_repo.git/info/exclude deleted file mode 100644 index a5196d1b..00000000 --- a/test/gpg/fixture_repo.git/info/exclude +++ /dev/null @@ -1,6 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ diff --git a/test/gpg/fixture_repo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/gpg/fixture_repo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 deleted file mode 100644 index adf64119..00000000 Binary files a/test/gpg/fixture_repo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 and /dev/null differ diff --git a/test/gpg/fixture_repo.git/objects/58/7be6b4c3f93f93c489c0111bba5596147a26cb b/test/gpg/fixture_repo.git/objects/58/7be6b4c3f93f93c489c0111bba5596147a26cb deleted file mode 100644 index 0df16772..00000000 Binary files a/test/gpg/fixture_repo.git/objects/58/7be6b4c3f93f93c489c0111bba5596147a26cb and /dev/null differ diff --git a/test/gpg/fixture_repo.git/objects/8d/152d2c8782eb8e8a7e7189adaec8560361fc8a b/test/gpg/fixture_repo.git/objects/8d/152d2c8782eb8e8a7e7189adaec8560361fc8a deleted file mode 100644 index ba5edf83..00000000 Binary files a/test/gpg/fixture_repo.git/objects/8d/152d2c8782eb8e8a7e7189adaec8560361fc8a and /dev/null differ diff --git a/test/gpg/fixture_repo.git/objects/9d/7bbf28841516b06ed91496fa15762fd60aaca1 b/test/gpg/fixture_repo.git/objects/9d/7bbf28841516b06ed91496fa15762fd60aaca1 deleted file mode 100644 index 21743829..00000000 Binary files a/test/gpg/fixture_repo.git/objects/9d/7bbf28841516b06ed91496fa15762fd60aaca1 and /dev/null differ diff --git a/test/gpg/fixture_repo.git/objects/a9/fcf7bcf27fd65b1460847c371bfbf5e9c4339c b/test/gpg/fixture_repo.git/objects/a9/fcf7bcf27fd65b1460847c371bfbf5e9c4339c deleted file mode 100644 index 68eb5d0f..00000000 Binary files a/test/gpg/fixture_repo.git/objects/a9/fcf7bcf27fd65b1460847c371bfbf5e9c4339c and /dev/null differ diff --git a/test/gpg/fixture_repo.git/refs/heads/master b/test/gpg/fixture_repo.git/refs/heads/master deleted file mode 100644 index 3dac632f..00000000 --- a/test/gpg/fixture_repo.git/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -a9fcf7bcf27fd65b1460847c371bfbf5e9c4339c diff --git a/test/gpg/generate_fixture_repo b/test/gpg/generate_fixture_repo deleted file mode 100755 index 9dc971ca..00000000 --- a/test/gpg/generate_fixture_repo +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -e -u -x - -# avoid importing fixture key into real keyring. -rm -rf /tmp/gpghome -mkdir /tmp/gpghome -export GNUPGHOME=/tmp/gpghome - -gpg --import private.key - -rm -rf fixture_repo.git - -git init --bare fixture_repo.git -rm fixture_repo.git/hooks/*.sample - -rm -rf repo -git clone fixture_repo.git repo -cd repo - -git \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q --allow-empty -m "init" - -echo x >> some-file -git add some-file - -echo enter passphrase: secret123 - -git \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q --gpg-sign=B0F5F8EF \ - -m "commit $(wc -l some-file) Test message" - -git push -u origin master - -cd .. -rm -rf repo diff --git a/test/gpg/private.key b/test/gpg/private.key deleted file mode 100644 index 7946fa39..00000000 --- a/test/gpg/private.key +++ /dev/null @@ -1,59 +0,0 @@ ------BEGIN PGP PRIVATE KEY BLOCK----- -Comment: GPGTools - https://gpgtools.org - -lQO+BFcYytwBCAC0TzTUf1Jq8YJmH5f216qoveoyVm11liXyHm0Q1H+C1Qx0fqgE -isrHoAGmVVyxj8MqhuilqdhJ3S3qPT5kQ/OIyBsC7+MaVOxqYtu5j9nJbHmW0+Tk -1FevDIf0zXHjqHnAHNumWjuMCNYP8TVr9x4OZ6qCkdu9u/2vXRF1e+lclKnkJRpJ -UHFZkrOnZ4yTXHOpfpCyfM7N/RvPQcmE2NHxOkQX1pFoEZND5waYFn3MMrSMe8CQ -WEpb8JaJ/cD4tl1N9eBiScFh1crz1zxluZCM6aHoDZwNfE90txFPRz72fMTSMCKZ -vY1GNhP+l9XudDXmAv2udgXUUGp8Cb1FFWabABEBAAH+AwMCApChaM3vM8nezztC -FmmeJz4XKoDEB2+nzwEJxy6MTaBZZ+ayTZgaHnsWBdJNmnMM5R6pX8uXCWxrray8 -3fyjXDZmlCroAZSjsJ72MQ53XoJ6C18QK8AZP6MYLH1DIwor236aVO7ngGvlJpve -kQ7//S9p2ILLEOI4EhO9wA5Hkj4ApQ/5S2TG8pfB6VnMV/JdQCPxxbFn1/78/Qlp -m1eVUvY4yp1d3xow1Ly6FeaIQFC8DPVcQGOQnlQvVr3M2rGAEkX0rcidgA5X+8QL -8YcsdovYX5UGxF13c9drEx33RkAFESsisZsR0indqvIKsq/083zC+cZBCLN7mIy/ -8CcFxSN+xI+MBMfxQt5OPY0xLCkGtp2LvVwSsOoDScV9bBab36QxFkSaXhvjHhJo -7cC9A+kAZ8DDN4HN3L1vpFD6E8IGcTEiRGx2Ymq7OzmeKNY3B8Tp5WRPRG6Fyhx/ -SjIFTdCB/hPpAa1TfPsdxHaxVJBYQJmdiG/uCp/AId2e0PysOKgEdV0tj6JN4PWI -8hnPEe8A8Ous3THGvqHC8KjCVJytHgoHJlP1U8396X7DDuc1fQe6/4xR9UwxWz/x -u6Y+YjfS4z0+rjxDHaqBYQti8dW01BLfARhhyuPB6P4ol8X1IQKCc+IUoAb1fTZV -4bbCPkzKc4gL6V9+7zTFlveevWPuChVz1rV6bw4VibWOT86/Pmuz1xtgpNNJanyZ -xLnO4ffPd54MzX0Yak3eD4r/cAQs+YXxM4GDWhW2cYNSKbsKBS61E0vAlTEXdMsX -GRxvFhjoveaja/sykiBI3eeXGYkN3cg18x64vhhhdh10scSV3AafHTTZ2GZcJxWK -UsFeAitlMaZlzZUM3QfzhUEx8H+WtIcUx0W3SvYfhuFsavO49mW0xbl6yHET0iM2 -DLQYVGVzdCAxIDx0ZXN0MUB0ZXN0MS5jb20+iQE3BBMBCgAhBQJXGMrcAhsDBQsJ -CAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJEBzdJa6w9fjv/FwH/04L3ivgWhsjEhJf -V/XLpxeZz2UK8Z5a57kDkW7kYq3/PiPwWDBWYFZsU1Fa7JS7G3YHqflSWl/Eyk0v -y0UX0dLsLFm3FPJ8K/24cIOvlFDi+TGtOvY3Q3RNKr9KAAoA9blFANRJvqp2BZBv -Y3iNjYtpj2yMexeEnPvh/LthCcu2v2OSMmYPIeQbDN75jQu4uUuXzRDG2Eqad7I+ -EfuR1XdaqKF7u/7dDwLcamspM3k2n+4bTpZCGxEMJ4x2L0fTILeLwUiGBITdDiqy -wWjfveCmeB0EZ450aI/PiR4Qm7ZGod5SqdZNHPFGEoaWW10tLzELoHHQKHJ217EP -11FczYadA74EVxjK3AEIAPFizAcS0QMgqNZsDNFCHRd6sK7WM3kq/FDPAEwT9/Qb -B1pPXOLZs/hEyBCqDeAOMfllwZpl/8VY/Xsf5NGimCdoaSKaRE5iUkhMx0/I71XD -0Z7UTQSHI1Lb/Ei0f46bzrFUxPnMdJddbsJPy/W6qCAPIx+/nx+ewjAYjn3chrjF -hMnprwXQvtAYCWdnO8pN1i+Ayg2z173RI6ewnPGSL1CE4FCVorcKRyVErt4nXkHK -apL7jcWyXrSYesFl8lynmxdZFrswE4g6Eem43XB4Az2dRYtv49juSIlCPgwiNdqq -JpuBtau/blBSi7cTeo/+soM6cIFhGhfEhjB/h+ovLw8AEQEAAf4DAwICkKFoze8z -yd7aGw7aQdMQhddGQwTVzQ/7JQQDinAUY/rO3kS2Kg+SEZ5ay4DnyUf8hJF7tSYP -lwqaJWdP4jfJm97RXvuVvmPS9c5+2E/Kbt97hS2D+hRxnFBxHYfHwHM4FZkErKoS -HpFwMBdTjn4hvOqXa6He4OOIcZc7epJeCraL+zhUUuDWeZP/HCuTpIx+acND4cl4 -OKRflc4XCTkCSZ09ur8fqBrcqB+izjndj9qtSkDMYqxixReZcAmD2zcLBp8JlUgw -2tYDj48RQDBlHm45inuEtN0H5qPo31oOpj87nCcB9eYXh9t+wOVh2ioEqlC0syWt -Fqi93jG8EZ4LGHeJ7yEMXzBmdFF/7bMuuZJvGT+7uvqYv9cOt5PMVFC+S/aT+VfF -Y6uTLIbQ6skdrxJr7Dps6nn0FM0oZM+LUoUmpF9uPZtqBl5eEbRX0uTKHbzj0CpX -u1vJ5nyEVTh4bja8TqqOcA0JCIoTUoFPFtbERgModX+OmXVuRyNN/W5NkwSbOavB -Idp8+MmNnT3UhNVjxpDXRZZgAAwLBLQrG/OLzh1nTwLXc4BdQyRaI/SNDzLzs9OW -EhPxtlvelZnvisPWmprazBzVeHN2fZrfwFzduUBcDBKlWveEKzO0GDrz1WV9eJxh -Y+6Ki03DOsAep8P+ZmJlP/xLMKc+LQwjWVw9XxB355t9OQskVpfqEHXavBcvVJY2 -cHB/t9SRvx8lI9DkQqyNWBBuRHthQvtmVWebcY4W79EATSSdakFOPTNDX0NpKAfX -e0Ty7YF4octB4AMKXnjcFYB1Cw7nQIX/AmXPlNlK+YawSo0PISid1A15zNN+LZ+V -QIhe/Ku59dkGfZR3QS5vg+1uUYe+L/lVaT76iEeMbmi3jHy2Ri7kIBinhMjpktF5 -9v5EwUaqiQEfBBgBCgAJBQJXGMrcAhsMAAoJEBzdJa6w9fjvXuEH/2mEXazgZ1Pb -ygMHzEmBVrRmOjyIkPn5n8oLVTS+mcoMQhyyCBYtqi6auXg/q1uo0QOxsUfnNjPy -44sRYhzvDt94rNbPt/ATJeWabx5256BdbOLlODNzj/HJPnMhWYBB/Wlg75C5p2w2 -J6SkyGIgA+WoLoiTAeWw/XFAJmZmXB9shjFLW7iyBEcSc8GlH54m0EOQbEEec2CC -ljSouaY9O04lLfRsVW2hdGK6BzUgpMlt7XeR8yjOGmbataCdQs38ycAIUlfHS+2J -wFEI1GL7DGFdGK9AZFX/zn7WkXMEV/AZ+4G5asXUI5OGCKVcdCiBcrl6hQtNW0ij -lFECmMvUceE= -=7DXW ------END PGP PRIVATE KEY BLOCK----- diff --git a/test/gpg/public.key b/test/gpg/public.key deleted file mode 100644 index 612ae14d..00000000 --- a/test/gpg/public.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Comment: GPGTools - https://gpgtools.org - -mQENBFcYytwBCAC0TzTUf1Jq8YJmH5f216qoveoyVm11liXyHm0Q1H+C1Qx0fqgE -isrHoAGmVVyxj8MqhuilqdhJ3S3qPT5kQ/OIyBsC7+MaVOxqYtu5j9nJbHmW0+Tk -1FevDIf0zXHjqHnAHNumWjuMCNYP8TVr9x4OZ6qCkdu9u/2vXRF1e+lclKnkJRpJ -UHFZkrOnZ4yTXHOpfpCyfM7N/RvPQcmE2NHxOkQX1pFoEZND5waYFn3MMrSMe8CQ -WEpb8JaJ/cD4tl1N9eBiScFh1crz1zxluZCM6aHoDZwNfE90txFPRz72fMTSMCKZ -vY1GNhP+l9XudDXmAv2udgXUUGp8Cb1FFWabABEBAAG0GFRlc3QgMSA8dGVzdDFA -dGVzdDEuY29tPokBNwQTAQoAIQUCVxjK3AIbAwULCQgHAwUVCgkICwUWAgMBAAIe -AQIXgAAKCRAc3SWusPX47/xcB/9OC94r4FobIxISX1f1y6cXmc9lCvGeWue5A5Fu -5GKt/z4j8FgwVmBWbFNRWuyUuxt2B6n5UlpfxMpNL8tFF9HS7CxZtxTyfCv9uHCD -r5RQ4vkxrTr2N0N0TSq/SgAKAPW5RQDUSb6qdgWQb2N4jY2LaY9sjHsXhJz74fy7 -YQnLtr9jkjJmDyHkGwze+Y0LuLlLl80QxthKmneyPhH7kdV3Wqihe7v+3Q8C3Gpr -KTN5Np/uG06WQhsRDCeMdi9H0yC3i8FIhgSE3Q4qssFo373gpngdBGeOdGiPz4ke -EJu2RqHeUqnWTRzxRhKGlltdLS8xC6Bx0ChydtexD9dRXM2GuQENBFcYytwBCADx -YswHEtEDIKjWbAzRQh0XerCu1jN5KvxQzwBME/f0GwdaT1zi2bP4RMgQqg3gDjH5 -ZcGaZf/FWP17H+TRopgnaGkimkROYlJITMdPyO9Vw9Ge1E0EhyNS2/xItH+Om86x -VMT5zHSXXW7CT8v1uqggDyMfv58fnsIwGI593Ia4xYTJ6a8F0L7QGAlnZzvKTdYv -gMoNs9e90SOnsJzxki9QhOBQlaK3CkclRK7eJ15BymqS+43Fsl60mHrBZfJcp5sX -WRa7MBOIOhHpuN1weAM9nUWLb+PY7kiJQj4MIjXaqiabgbWrv25QUou3E3qP/rKD -OnCBYRoXxIYwf4fqLy8PABEBAAGJAR8EGAEKAAkFAlcYytwCGwwACgkQHN0lrrD1 -+O9e4Qf/aYRdrOBnU9vKAwfMSYFWtGY6PIiQ+fmfygtVNL6ZygxCHLIIFi2qLpq5 -eD+rW6jRA7GxR+c2M/LjixFiHO8O33is1s+38BMl5ZpvHnbnoF1s4uU4M3OP8ck+ -cyFZgEH9aWDvkLmnbDYnpKTIYiAD5aguiJMB5bD9cUAmZmZcH2yGMUtbuLIERxJz -waUfnibQQ5BsQR5zYIKWNKi5pj07TiUt9GxVbaF0YroHNSCkyW3td5HzKM4aZtq1 -oJ1CzfzJwAhSV8dL7YnAUQjUYvsMYV0Yr0BkVf/OftaRcwRX8Bn7gblqxdQjk4YI -pVx0KIFyuXqFC01bSKOUUQKYy9Rx4Q== -=UH8b ------END PGP PUBLIC KEY BLOCK----- diff --git a/test/gpg/unknown_public.key b/test/gpg/unknown_public.key deleted file mode 100644 index b525d0f0..00000000 --- a/test/gpg/unknown_public.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Comment: GPGTools - https://gpgtools.org - -mQENBFcaMHABCADLYvmDpfRz5LnhkVznLlhUN6T3wlRXjNCPYF541KcKNyUlBDjQ -P4u9ZiM9Vbvt67JV3WHPe8WAq/rmhl1MtNupnyoAlpl2ubag/JTrE0qbpzozDbAa -ONNinL+eWpueiZUFXIeG/M0xyfRQhWxcmOPC8qTT9BaRC6ckkuc/tTXcsV/DlmJ6 -AVkUrI8lHVmeqaYBHYZ0dayIn8GSrRvxh9KV9Oetesb/dwoFtpcTlNajsi96HDUC -8ohi3m1C0meTbm4RuLoriyX3T4nBhur18D/n0YFjB+zJtjd7g3dLwYk6Ggt9jeg2 -nmo5ll2LYo+XUA7KlY49uDcM8QKO4pYISQJpABEBAAG0D2FhYWFhIDxhQGEuY29t -PokBNwQTAQoAIQUCVxowcAIbAwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRCO -qwuN7ibl/SPqCACynQHxTpdsy9w9o2imRrh5YgefZuIQT2OMzmd+9Nc1gzztSjbe -jXQ3SI/O2JnrMRP1a0BgibaWvzyR1XwIwvk+CVPkwo2scSsLr2ixd4uacnOECvwl -QvChhXjqwO0bmwEJtK9W0tcNomM0miGjsbwL/M5zj9M/GNKKUQmZ+ZIpcBcQCBXi -+vZNf5y8zPutMfB6/NEoC/uOhSzUbmq6fhcZ+emwt4xMDWMez0aBw6vwFWmiXnf4 -ePlkXW5PKe+HSc1uAxC2fMMIxW4tE05gROABpnFNgNSIS9NmwOJhpUjbhADr2M49 -57AF6VBOhLSdVMwVyvsoCmlukHyTkovV4t7xuQENBFcaMHABCACqj/U6h6cScEzf -D6M73rOqL6d+qQOdFGGRDf2OPQlYIRect8/wSA8uMy08eXQ35KV+ynoah13PK04E -0pQ60TvzuX0o/QIDJyen6CKNoUUF7mDphFc/XBypOfkkzmVlv/lmarXmtYC2yXor -QEJeXvZJWzsR7gTTTE7YyMMpyDqcFfuYFIFskLXWxyPYXiMM86HGMioxXOcJz/e2 -6Z0aN3SJflymltCCXbxT52zWCMiTbf6yPvVZPvlhMplXN+0m6VGyv8XgX578l9an -CEaZ8e4FK3s1a2mpWL63X60ynYTl6Y1hnHblNmiMpTxv7JQd8aHLaqSIrEZHwqZ0 -c6tHL7UpABEBAAGJAR8EGAEKAAkFAlcaMHACGwwACgkQjqsLje4m5f03+wgAu28O -ovfW2tghKuHLbGtLwQ513IXVUoqNup3Vpn5vLJaXWN1Ifzd/tYYKGNS6VQChK0Bo -hWThIeGulPbxbiDikWVrRAmUGcxEH5mkWPob1mTFYJt/evV/cvLzA5800oaijTkd -IOcw4NhYbCJbmeqE+VN9AdcyBtDF+Cag1ibQ+t+4H8LBdot1+AmKVTT4YdouNnAv -qt3biEgGjjVTbe3BFKR7LNhK/lEKOLSGlCXioVjJcW1avYfC2nJpjss2S85r0aRL -0lzSCBG/UO1T/gwCtBtezLePHdSWiSRXlhVualv8KajPJj8Ivqyaimd2bemQuwtc -ntcN5BBIRaGlgXs5cg== -=nw3D ------END PGP PUBLIC KEY BLOCK----- diff --git a/test/helpers.sh b/test/helpers.sh deleted file mode 100644 index 17a7a728..00000000 --- a/test/helpers.sh +++ /dev/null @@ -1,1699 +0,0 @@ -#!/bin/bash - -set -e -u - -set -o pipefail - -export TMPDIR_ROOT=$(mktemp -d /tmp/git-tests.XXXXXX) -trap "rm -rf $TMPDIR_ROOT" EXIT - -if [ -d /opt/resource ]; then - resource_dir=/opt/resource -else - resource_dir=$(cd $(dirname $0)/../assets && pwd) -fi -test_dir=$(cd $(dirname $0) && pwd) -keygrip=276D99F5B65388AF85DF54B16B08EF0A44C617AC -fingerprint=A3E20CD6371D49E244B0730D1CDD25AEB0F5F8EF - -run() { - export TMPDIR=$(mktemp -d ${TMPDIR_ROOT}/git-tests.XXXXXX) - - echo -e 'running \e[33m'"$@"$'\e[0m...' - eval "$@" 2>&1 | sed -e 's/^/ /g' - echo "" -} - -init_repo() { - ( - set -e - - cd $(mktemp -d $TMPDIR/repo.XXXXXX) - - git init -q - - # Disable automatic gc/maintenance. git >= 2.54 forks background maintenance - # (repack/prune/commit-graph) after commits; with the rapid commits some - # tests create, this races the foreground commits and corrupts the fixture, - # surfacing as flaky "could not read"/"unable to parse commit" failures. - git config gc.auto 0 - git config maintenance.auto false - - # start with an initial commit - local commit_date=$(_test_seq_date $(_test_next_seq .)) - GIT_COMMITTER_DATE="$commit_date" git \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q --allow-empty -m "init" \ - --date "$commit_date" - - # create some bogus branch - git checkout -q -b bogus - - commit_date=$(_test_seq_date $(_test_next_seq .)) - GIT_COMMITTER_DATE="$commit_date" git \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q --allow-empty -m "commit on other branch" \ - --date "$commit_date" - - # back to master - git checkout -q master - - # print resulting repo - pwd - ) -} - -init_repo_with_submodule() { - local submodule=$(init_repo) - make_commit $submodule >/dev/null - make_commit $submodule >/dev/null - - local project=$(init_repo) - git -C $project submodule add "file://$submodule" >/dev/null - git -C $project commit -m "Adding Submodule" >/dev/null - echo $project,$submodule -} - -init_repo_with_named_submodule() { - local name=$1 - local path=$2 - - local submodule=$(init_repo) - make_commit $submodule >/dev/null - make_commit $submodule >/dev/null - - local project=$(init_repo) - git -C $project submodule add --name $1 "file://$submodule" $2 >/dev/null - git -C $project commit -m "Adding Submodule" >/dev/null - echo $project,$submodule -} - -init_repo_with_submodule_missing_path() { - local name=$1 - local path=$2 - - local submodule=$(init_repo) - local project=$(init_repo) - - { - make_commit $submodule - make_commit $submodule - - git -C $project submodule add --name $name "file://$submodule" $path - git -C $project commit -m "Adding Submodule" - git -C $project rm $path - git -C $project reset .gitmodules - git -C $project checkout .gitmodules - git -C $project commit -m "Breaking Submodule" - } >&2 - - echo $project,$submodule -} - -init_repo_with_submodule_of_nested_submodule() { - local submodule_and_nested_submodule=$(init_repo_with_submodule) - local nested_submodule=$(echo $submodule_and_nested_submodule | cut -d "," -f2) - local submodule=$(echo $submodule_and_nested_submodule | cut -d "," -f1) - make_commit $submodule >/dev/null - make_commit $submodule >/dev/null - - local project=$(init_repo) - git -C $project submodule add "file://$submodule" >/dev/null - git -C $project commit -m "Adding Submodule" >/dev/null - echo $project,$submodule,$nested_submodule -} - -fetch_head_ref() { - local repo=$1 - - git -C $repo rev-parse HEAD -} - -# Per-repo monotonic counter used to give commits and waited tags distinct, -# deterministic timestamps. git's committer-date and tag creator-date have -# 1-second resolution; tests previously got distinct timestamps with `sleep 1`, -# which made the suite slow. The counter is persisted to a file so it survives -# the command-substitution subshells callers use. -_test_next_seq() { - local repo=$1 - local seq_file="$repo/.git/.test_seq" - local seq=$(( $(cat "$seq_file" 2>/dev/null || echo 0) + 1 )) - echo "$seq" > "$seq_file" - echo "$seq" -} - -_test_seq_date() { - date -u -d "@$(( 946684800 + $1 ))" "+%Y-%m-%d %H:%M:%S +0000" -} - -make_commit_to_file_on_branch() { - local repo=$1 - local file=$2 - local branch=$3 - local msg=${4-} - - # ensure branch exists - if ! git -C $repo rev-parse --verify $branch &>/dev/null; then - git -C $repo branch $branch master - fi - - # switch to branch - git -C $repo checkout -q $branch - - # modify file and commit - echo x >> $repo/$file - git -C $repo add $file - - if [ "$file" = "future-file" ]; then - # if future-file, create a commit with date in the future - # Usefull to veryfy if git rev-list return the real latest commit - GIT_COMMITTER_DATE="$(date -R -d '1 year')" git -C $repo \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q -m "commit $(wc -l $repo/$file) $msg" \ - --date "$(date -R -d '1 year')" - else - local commit_date=$(_test_seq_date $(_test_next_seq $repo)) - GIT_COMMITTER_DATE="$commit_date" git -C $repo \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q -m "commit $(wc -l $repo/$file) $msg" \ - --date "$commit_date" - fi - - # output resulting sha - git -C $repo rev-parse HEAD -} - -make_commit_to_file_on_branch_with_path() { - local repo=$1 - local path=$2 - local file=$3 - local branch=$4 - local msg=${5-} - - # ensure branch exists - if ! git -C $repo rev-parse --verify $branch &>/dev/null; then - git -C $repo branch $branch master - fi - - # switch to branch - git -C $repo checkout -q $branch - - # modify file and commit - mkdir -p $repo/$path - echo x >> $repo/$path/$file - git -C $repo add $path/$file - local commit_date=$(_test_seq_date $(_test_next_seq $repo)) - GIT_COMMITTER_DATE="$commit_date" git -C $repo \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q -m "commit $(wc -l $repo/$path/$file) $msg" \ - --date "$commit_date" - - # output resulting sha - git -C $repo rev-parse HEAD -} - -make_commit_to_file() { - make_commit_to_file_on_branch $1 $2 master "${3-}" -} - -make_commit_to_branch() { - make_commit_to_file_on_branch $1 some-file $2 -} - -make_commit() { - make_commit_to_file $1 some-file "${2:-}" -} - -make_commit_to_future() { - make_commit_to_file $1 future-file "${2:-}" -} - -make_commit_to_be_skipped() { - make_commit_to_file $1 some-file "[ci skip]" -} - -make_commit_to_be_skipped2() { - make_commit_to_file $1 some-file "[skip ci]" -} - - -merge_branch() { - local repo=$1 - local target=$2 - local branch=$3 - - # switch to branch - git -C $repo checkout -q $target - - # merge in branch - git -C $repo merge -q --no-ff $branch - - # output resulting sha - git -C $repo rev-parse HEAD -} - -delete_public_key() { - if gpg -k ${fingerprint} &> /dev/null; then - gpg --batch --yes --delete-keys ${fingerprint} - fi -} - -gpg_fixture_repo_path() { - echo "${test_dir}/gpg/fixture_repo.git" -} - -git_crypt_fixture_repo_path() { - echo "${test_dir}/git-crypt/fixture_repo.git" -} - -git_crypt_fixture_key_path() { - echo "${test_dir}/git-crypt/fixture_repo.key" -} - -make_empty_commit() { - local repo=$1 - local msg=${2-} - - local commit_date=$(_test_seq_date $(_test_next_seq $repo)) - GIT_COMMITTER_DATE="$commit_date" git -C $repo \ - -c user.name='test' \ - -c user.email='test@example.com' \ - commit -q --allow-empty -m "commit $msg" \ - --date "$commit_date" - - # output resulting sha - git -C $repo rev-parse HEAD -} - -make_annotated_tag() { - local repo=$1 - local tag=$2 - local msg=$3 - local wait=${4:-false} - - if [ "$wait" == true ]; then - # Give each successive waited tag a distinct, increasing creation date so tags - # sort deterministically. The shared per-repo counter (see _test_next_seq) is - # also bumped by commits, so commit and tag ordering interleaves correctly. - GIT_COMMITTER_DATE="$(_test_seq_date $(_test_next_seq $repo))" \ - git -C $repo tag -f -a "$tag" -m "$msg" - else - git -C $repo tag -f -a "$tag" -m "$msg" - fi - - git -C $repo describe --tags --abbrev=0 -} - -make_lightweight_tag() { - local repo=$1 - local tag=$2 - local wait=${3:-false} - - if [ "$wait" == true ]; then - # lightweight tags don't use $GIT_COMMITTER_DATE since they point to a - # commit object with an existing creatordate. To ensure order of tag - # creation is respected in our tests, create a new commit and make the - # lightweight tag against that commit - make_commit $repo - git -C $repo tag -f "$tag" - else - git -C $repo tag -f "$tag" - fi - - git -C $repo describe --tags --abbrev=0 -} - -check_uri() { - jq -n --arg uri "$1" '{ - source: { - uri: $uri - } - }' | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_unknown_key() { - jq -n --arg uri "$1" '{ - source: { - uri: $uri, - some_key: "thats unknown" - } - }' | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_branch() { - jq -n \ - --arg uri "$1" \ - --arg branch "$2" '{ - source: { - uri: $uri, - branch: $branch - } - }' | ${resource_dir}/check | tee /dev/stderr -} - -get_initial_ref() { - local repo=$1 - - git -C $repo rev-list HEAD | tail -n 1 -} - -check_uri_with_key() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - private_key: $(cat $2 | jq -s -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_key_and_passphrase() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - private_key: $(cat $2 | jq -s -R .), - private_key_passphrase: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_credentials() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - username: $(echo $2 | jq -R .), - password: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_submodule_credentials() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - username: $(echo $2 | jq -R .), - password: $(echo $3 | jq -R .), - submodule_credentials: [ - { - host: $(echo $4 | jq -R .), - username: $(echo $5 | jq -R .), - password: $(echo $6 | jq -R .) - } - ] - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_credential_hosts() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - username: $(echo $2 | jq -R .), - password: $(echo $3 | jq -R .), - credential_hosts: $(echo "$4" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_ignoring() { - local uri=$1 - - shift - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - ignore_paths: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_paths() { - local uri=$1 - - shift - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - paths: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_paths_ignoring() { - local uri=$1 - local paths=$2 - - shift 2 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - paths: [$(echo $paths | jq -R .)], - ignore_paths: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_from() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - version: { - ref: $(echo $2 | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_version_depth() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - version_depth: $(echo $2 | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_filter_and_version_depth() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - version_depth: $(echo $2 | jq -R .), - tag_filter: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_from_ignoring() { - local uri=$1 - local ref=$2 - - shift 2 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - ignore_paths: $(echo "$@" | jq -R '. | split(" ")') - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_from_paths_disable_ci_skip() { - local uri=$1 - local ref=$2 - - shift 2 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - paths: $(echo "$@" | jq -R '. | split(" ")'), - disable_ci_skip: true - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_from_paths() { - local uri=$1 - local ref=$2 - - shift 2 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - paths: $(echo "$@" | jq -R '. | split(" ")') - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_from_paths_with_branch() { - local uri=$1 - local branch=$2 - - shift 2 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - paths: $(echo "$@" | jq -R '. | split(" ")'), - branch: $(echo $branch | jq -R .), - disable_ci_skip: true - }, - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_from_paths_ignoring() { - local uri=$1 - local ref=$2 - local paths=$3 - - shift 3 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - paths: [$(echo $paths | jq -R .)], - ignore_paths: $(echo "$@" | jq -R '. | split(" ")') - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_filter() { - local uri=$1 - local tag_filter=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_filter: $(echo "$tag_filter" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_and_path_filter() { - local uri=$1 - local tag_filter=$2 - local tag_behaviour=$3 - - shift 3 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_filter: $(echo "$tag_filter" | jq -R .), - tag_behaviour: $(echo "$tag_behaviour" | jq -R .), - paths: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_regex() { - local uri=$1 - local tag_regex=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_regex: $(echo $tag_regex | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_filter_given_branch() { - local uri=$1 - local tag_filter=$2 - local branch=$3 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_filter: $(echo $tag_filter | jq -R .), - branch: $(echo $branch | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_regex_given_branch() { - local uri=$1 - local tag_regex=$2 - local branch=$3 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_regex: $(echo $tag_regex | jq -R .), - branch: $(echo $branch | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_filter_from() { - local uri=$1 - local tag_filter=$2 - local ref=$3 - local version_depth=${4:-1} - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_filter: $(echo $tag_filter | jq -R .), - version_depth: $(echo $version_depth | jq -R .) - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tag_regex_from() { - local uri=$1 - local tag_regex=$2 - local ref=$3 - local version_depth=${4:-1} - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - tag_regex: $(echo $tag_regex | jq -R .), - version_depth: $(echo $version_depth | jq -R ) - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_config() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - git_config: [ - { - name: \"core.pager\", - value: \"true\" - }, - { - name: \"credential.helper\", - value: \"!true long command with variables \$@\" - } - ] - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_disable_ci_skip() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - disable_ci_skip: true - }, - version: { - ref: $(echo $2 | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_key_and_ssh_agent() { - local uri=$1 - local key=$2 - local agent=$3 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - private_key: $(cat $2 | jq -s -R .), - forward_agent: $agent - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_key_and_private_key_user() { - local uri=$1 - local key=$2 - local user=$3 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - private_key: $(cat $key | jq -s -R .), - private_key_user: $(echo $user | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_filter() { - local uri=$1 - local ref=$2 - local type=$3 - local value=$4 - local all_match=${5:-"false"} - - jq -n "{ - source: { - uri: $(echo $uri| jq -R .), - commit_filter: { - $(echo $type | jq -R .): $(echo -en $value | jq -sR 'split("\n") | if type=="string" then [.] else . end' ), - $(echo $type"_all_match" | jq -R .): $(echo $all_match | jq -R .) - - } - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_filters() { - local uri=$1 - local ref=$2 - local included=$3 - local excluded=$4 - - jq -n "{ - source: { - uri: $(echo $uri| jq -R .), - commit_filter: { - include: [ - $(echo $included | jq -R .) - ], - exclude: [ - $(echo $excluded | jq -R .) - ] - } - }, - version: { - ref: $(echo $ref | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_branches() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - version_type: \"branches\" - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_branches_from() { - local uri=$1 - local prev_branches=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"branches\" - }, - version: { - branches: $(echo "$prev_branches" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_branch_filters() { - local uri=$1 - shift - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"branches\", - branch_filters: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_branch_regex() { - local uri=$1 - local branch_regex=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"branches\", - branch_regex: $(echo "$branch_regex" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_branch_filters_and_regex() { - local uri=$1 - local branch_regex=$2 - shift 2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"branches\", - branch_filters: $(echo "$@" | jq -R '. | split(" ")'), - branch_regex: $(echo "$branch_regex" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - version_type: \"tags\" - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags_filter() { - local uri=$1 - local tag_filter=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\", - tag_filter: $(echo "$tag_filter" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags_filters() { - local uri=$1 - shift - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\", - tag_filters: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags_filter_and_filters() { - local uri=$1 - local tag_filter=$2 - shift 2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\", - tag_filter: $(echo "$tag_filter" | jq -R .), - tag_filters: $(echo "$@" | jq -R '. | split(" ")') - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags_regex() { - local uri=$1 - local tag_regex=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\", - tag_regex: $(echo "$tag_regex" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags_sort() { - local uri=$1 - local tag_sort=$2 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\", - tag_sort: $(echo "$tag_sort" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -check_uri_with_tags_sort_from() { - local uri=$1 - local tag_sort=$2 - local prev_tag=$3 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\", - tag_sort: $(echo "$tag_sort" | jq -R .) - }, - version: { - tag: $(echo "$prev_tag" | jq -R .) - } - }" | ${resource_dir}/check | tee /dev/stderr -} - -get_uri() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - }, - params: { - short_ref_format: \"test-%s\" - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_unknown_keys() { - jq -n \ - --arg uri "$1" '{ - source: { - uri: $uri, - }, - params: { - short_ref_format: "test-%s", - unknown_key: "some-value", - other_key: "another-value" - } - }' | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_disable_lfs() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - }, - params: { - short_ref_format: \"test-%s\", - disable_git_lfs: \"true\" - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_branch() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .), - }, - params: { - short_ref_format: \"test-%s\" - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_with_override_branch() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - short_ref_format: \"test-%s\" - }, - version: { - branch: $(echo $2 | jq -R .), - ref: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/in "$4" | tee /dev/stderr -} - -get_uri_with_git_crypt_key() { - local git_crypt_key_path=$(git_crypt_fixture_key_path) - local git_crypt_key_base64_encoded=$(cat $git_crypt_key_path | base64) - - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - git_crypt_key: $(echo $git_crypt_key_base64_encoded | jq -R .) - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_at_depth() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - depth: $(echo $2 | jq -R .) - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_at_depth_at_ref() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - depth: $(echo $2 | jq -R .) - }, - version: { - ref: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/in "$4" | tee -a /dev/stderr -} - -get_uri_with_submodules_at_depth() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - depth: $(echo $2 | jq -R .), - submodules: [$(echo $3 | jq -R .)], - } - }" | ${resource_dir}/in "$4" | tee /dev/stderr -} - -get_uri_with_submodules_all() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - depth: $(echo $2 | jq -R .), - submodules: \"all\", - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_with_submodules_and_parameter_remote() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - depth: $(echo $2 | jq -R .), - submodules: $(echo $3 | jq -R .), - submodule_remote: $(echo $4 | jq -R .), - } - }" | ${resource_dir}/in "$5" | tee /dev/stderr -} - -get_uri_with_submodules_and_parameter_recursive() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - depth: $(echo $2 | jq -R .), - submodules: $(echo $3 | jq -R .), - submodule_recursive: $(echo $4 | jq -R .), - } - }" | ${resource_dir}/in "$5" | tee /dev/stderr -} - -get_uri_at_ref() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - version: { - ref: $(echo $2 | jq -R .) - }, - params: { - short_ref_format: \"test-%s\" - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_at_branch() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .) - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_at_branch_without_fetch_tags() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .) - }, - params: { - fetch_tags: \"false\" - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_at_branch_with_fetch_tags() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .) - }, - params: { - fetch_tags: \"true\" - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -get_uri_at_branch_with_ref() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .) - }, - version: { - ref: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/in "$4" | tee /dev/stderr -} - -get_uri_at_branch_with_search_remote_refs() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .), - search_remote_refs: true - }, - version: { - ref: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/in "$4" | tee /dev/stderr -} - -get_uri_with_config() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - git_config: [ - { - name: \"core.pager\", - value: \"true\" - }, - { - name: \"credential.helper\", - value: \"!true long command with variables \$@\" - } - ] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_verification_key() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - commit_verification_keys: [\"$(cat ${test_dir}/gpg/public.key)\"] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr - exit_code=$? - delete_public_key - return ${exit_code} -} - -get_uri_with_verification_key_and_tag_filter() { - local uri=$1 - local dest=$2 - local tag_filter=$3 - local version=$4 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - commit_verification_keys: [\"$(cat ${test_dir}/gpg/public.key)\"], - tag_filter: $(echo $tag_filter | jq -R .) - }, - version: { - ref: $(echo $version | jq -R .) - } - }" | ${resource_dir}/in "$dest" | tee /dev/stderr - exit_code=$? - delete_public_key - return ${exit_code} -} - -get_uri_with_verification_key_and_tag_regex() { - local uri=$1 - local dest=$2 - local tag_regex=$3 - local version=$4 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - commit_verification_keys: [\"$(cat ${test_dir}/gpg/public.key)\"], - tag_regex: $(echo $tag_regex | jq -R .) - }, - version: { - ref: $(echo $version | jq -R .) - } - }" | ${resource_dir}/in "$dest" | tee /dev/stderr - exit_code=$? - delete_public_key - return ${exit_code} -} - -get_uri_with_invalid_verification_key() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - commit_verification_keys: [\"abcd\"] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_unknown_verification_key() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - commit_verification_keys: [\"$(cat ${test_dir}/gpg/unknown_public.key)\"] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr - exit_code=$? - delete_public_key - return ${exit_code} -} - -get_uri_when_using_keyserver() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - commit_verification_key_ids: [\"A3E20CD6371D49E244B0730D1CDD25AEB0F5F8EF\"] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr - exit_code=$? - delete_public_key - return ${exit_code} -} - -get_uri_when_using_keyserver_and_bogus_key() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - commit_verification_key_ids: [\"abcd\"] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_when_using_keyserver_and_unknown_key() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - commit_verification_key_ids: [\"24C51CCE1AB7B2EFEF72B9A48EAB0B8DEE26E5FD\"] - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_clean_tags() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - clean_tags: $(echo $3 | jq -R .), - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_custom_timestamp() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - }, - params: { - timestamp_format: \"$3\" - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_sparse() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - sparse_paths: $(echo "$@" | jq -R '. | split(" ")') - }, - params: { - short_ref_format: \"test-%s\" - } - }" | ${resource_dir}/in "$2" | tee /dev/stderr -} - -get_uri_with_fetch_branches() { - local uri=$1 - local fetch_branches=$2 - local dest=$3 - jq -n "{ - source: { - uri: $(echo $uri | jq -R .) - }, - params: { - fetch: $(echo $fetch_branches | jq -R 'split(" ")') - } - }" | ${resource_dir}/in "$dest" | tee /dev/stderr -} - -get_branches() { - local uri=$1 - local branches=$2 - local dest=$3 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"branches\" - }, - version: { - branches: $(echo $branches | jq -R .) - } - }" | ${resource_dir}/in "$dest" | tee /dev/stderr -} - -get_tags() { - local uri=$1 - local tag=$2 - local dest=$3 - - jq -n "{ - source: { - uri: $(echo $uri | jq -R .), - version_type: \"tags\" - }, - version: { - tag: $(echo $tag | jq -R .) - } - }" | ${resource_dir}/in "$dest" | tee /dev/stderr -} - -get_uri_with_all_branches() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: $(echo $2 | jq -R .), - }, - params: { - all_branches: \"true\" - } - }" | ${resource_dir}/in "$3" | tee /dev/stderr -} - -put_uri() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_unknown_keys() { - jq -n \ - --arg uri "$1" \ - --arg repo "$3" '{ - source: { - uri: $uri, - branch: "master" - }, - params: { - repository: $repo, - unknown_key: "some-value", - other_key: "another-value" - } - }' | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_branch() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .) - }, - params: { - repository: $(echo $3 | jq -R .), - branch: $(echo $4 | jq -R .), - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_force() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - force: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_only_tag() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - }, - params: { - repository: $(echo $3 | jq -R .), - only_tag: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_only_tag_with_force() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - only_tag: true, - force: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - rebase: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_merge() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - merge: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_merge_returning_unmerged() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - merge: true, - returning: \"unmerged\" - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_merge_and_rebase() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - merge: true, - rebase: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_tag() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - tag: $(echo $3 | jq -R .), - repository: $(echo $4 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_tag_and_prefix() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - tag: $(echo $3 | jq -R .), - tag_prefix: $(echo $4 | jq -R .), - repository: $(echo $5 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_tag_and_annotation() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - tag: $(echo $3 | jq -R .), - annotate: $(echo $4 | jq -R .), - repository: $(echo $5 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase_with_tag() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - tag: $(echo $3 | jq -R .), - repository: $(echo $4 | jq -R .), - rebase: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase_with_tag_and_prefix() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - tag: $(echo $3 | jq -R .), - tag_prefix: $(echo $4 | jq -R .), - repository: $(echo $5 | jq -R .), - rebase: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase_strategy_option() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - rebase: true, - rebase_strategy_option: $(echo $4 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase_multiple_options_string() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - rebase: true, - rebase_strategy_option: \"theirs ignore-space-change\" - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase_multiple_options_array() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - rebase: true, - rebase_strategy_option: [\"theirs\", \"ignore-space-change\"] - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_notes() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - notes: $(echo $3 | jq -R .), - repository: $(echo $4 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_rebase_with_notes() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - notes: $(echo $3 | jq -R .), - repository: $(echo $4 | jq -R .), - rebase: true - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_config() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\", - git_config: [ - { - name: \"core.pager\", - value: \"true\" - }, - { - name: \"credential.helper\", - value: \"!true long command with variables \$@\" - } - ] - }, - params: { - repository: $(echo $3 | jq -R .) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_refs_prefix() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - refs_prefix: $(echo $4 | jq -R .), - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -put_uri_with_push_options() { - jq -n "{ - source: { - uri: $(echo $1 | jq -R .), - branch: \"master\" - }, - params: { - repository: $(echo $3 | jq -R .), - push_options: $(echo $4) - } - }" | ${resource_dir}/out "$2" | tee /dev/stderr -} - -get_github_app_private_key() { - local key="${TMPDIR}/github_app_key" - if [[ ! -e "$key" ]]; then - ssh-keygen -f "${key}" -m PEM -t rsa -b 2048 -q -N "" - fi - cat "$key" -} - -get_github_app_private_key_json() { - jq -Rs . <<< "$(get_github_app_private_key)" -} diff --git a/test/image.sh b/test/image.sh deleted file mode 100755 index 0d1ff5c8..00000000 --- a/test/image.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -e - -. "$(dirname "$0")/helpers.sh" - -it_has_installed_git_lfs() { - git lfs env -} - -it_has_installed_proxytunnel() { - test -x /usr/bin/proxytunnel -} - -it_cleans_up_installation_artifacts() { - test ! -d git_lfs_install* - test ! -d /root/proxytunnel -} - -run it_has_installed_git_lfs -run it_has_installed_proxytunnel -run it_cleans_up_installation_artifacts diff --git a/test/lfs.sh b/test/lfs.sh deleted file mode 100755 index acd662d9..00000000 --- a/test/lfs.sh +++ /dev/null @@ -1,36 +0,0 @@ -set -e - -source $(dirname $0)/helpers.sh - -lfsrepo="https://github.com/concourse/lfs-test-repo" - -# These tests work by cloning the $lfsrepo specified above. The repo contains -# just a file "test", which is served via LFS. If we get the LFS file, the -# file will contain only the string "SUCCESS". If we do NOT get the LFS file, -# then the file will contain an LFS pointer to the file. These tests verify -# that we DO and DON'T fetch the LFS file as expected, based upon the presenece -# of the git_disable_lfs parameter. - -it_can_clone_with_lfs() { - cd $(mktemp -d $TMPDIR/repo.XXXXXX) - local dest=$TMPDIR/destination - - get_uri $lfsrepo $dest - - test -e "$dest/test" - test "$(cat $dest/test)" = "SUCCESS" -} - -it_can_clone_with_lfs_disabled() { - cd $(mktemp -d $TMPDIR/repo.XXXXXX) - local dest=$TMPDIR/destination - - get_uri_disable_lfs $lfsrepo $dest - - test -e "$dest/test" - test "$(cat $dest/test)" != "SUCCESS" -} - -run it_can_clone_with_lfs -run it_can_clone_with_lfs_disabled - diff --git a/test/put.sh b/test/put.sh deleted file mode 100755 index 3fd3e1c0..00000000 --- a/test/put.sh +++ /dev/null @@ -1,869 +0,0 @@ -#!/bin/bash - -set -e - -source $(dirname $0)/helpers.sh - -it_can_put_to_url() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # create a tag to push - git -C $repo2 tag some-tag - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri $repo1 $src repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - test "$(git -C $repo1 rev-parse some-tag)" = $ref -} - -it_can_put_to_url_with_branch() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local branch="branch-a" - local ref=$(make_commit_to_branch $repo2 $branch) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_branch $repo1 $src repo $branch | jq -e " - .version == {branch: $(echo $branch | jq -R .), ref: $(echo $ref | jq -R .)} - " - - # switch to branch-a - git -C $repo1 checkout $branch - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref -} - -it_returns_branch_in_metadata() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # create a tag to push - git -C $repo2 tag some-tag - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri $repo1 $src repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - and - (.metadata | .[] | select(.name == \"branch\") | .value == $(echo master | jq -R .)) - " -} - -it_can_put_to_url_with_tag() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - echo some-tag-name > $src/some-tag-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_tag $repo1 $src some-tag-file repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - test "$(git -C $repo1 rev-parse some-tag-name)" = $ref -} - -it_can_put_to_url_with_tag_and_prefix() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - echo 1.0 > $src/some-tag-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_tag_and_prefix $repo1 $src some-tag-file v repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - test "$(git -C $repo1 rev-parse v1.0)" = $ref -} - -it_can_put_to_url_with_tag_and_annotation() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - mkdir -p $src/tag - echo 1.0 > $src/tag/some-tag-file - echo yay > $src/tag/some-annotation-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_tag_and_annotation $repo1 $src "tag/some-tag-file" "tag/some-annotation-file" repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - - # Annotated tags have a different hash so resolve the reference - test "$(git -C $repo1 rev-parse 1.0^{commit})" = $ref - test "$(git -C $repo1 rev-parse 1.0)" != $ref -} - -it_can_put_to_url_with_rebase() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # make a commit that will require rebasing - local baseref=$(make_commit_to_file $repo1 some-other-file) - - local ref=$(make_commit $repo2) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_rebase $repo1 $src repo > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref -} - -it_can_put_to_url_with_rebase_with_tag() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # make a commit that will require rebasing - local baseref=$(make_commit_to_file $repo1 some-other-file) - - local ref=$(make_commit $repo2) - - echo some-tag-name > $src/some-tag-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_rebase_with_tag $repo1 $src some-tag-file repo > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref - test "$(git -C $repo1 rev-parse some-tag-name)" = $rebased_ref -} - -it_can_put_to_url_with_rebase_with_tag_and_prefix() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # make a commit that will require rebasing - local baseref=$(make_commit_to_file $repo1 some-other-file) - - local ref=$(make_commit $repo2) - - echo 1.0 > $src/some-tag-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_rebase_with_tag_and_prefix $repo1 $src some-tag-file v repo > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref - test "$(git -C $repo1 rev-parse v1.0)" = $rebased_ref -} - - -it_can_put_to_url_with_rebase_strategy_options() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # create initial commit with a file both will modify - echo "original" > $repo1/conflict-file - git -C $repo1 add conflict-file - git -C $repo1 commit -m "initial" - git -C $repo2 pull - - # make a commit that will conflict when rebasing - local baseref=$(make_commit_to_file $repo1 conflict-file) - - # make a conflicting local commit - echo "local" > $repo2/conflict-file - git -C $repo2 add conflict-file - git -C $repo2 commit -m "local change" - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_rebase_strategy_option $repo1 $src repo "theirs" > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/conflict-file - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref -} - -it_can_put_with_rebase_ignore_space_change() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # create a file with specific spacing - printf "line1\nline2 \nline3\n" > $repo1/spacefile - git -C $repo1 add spacefile - git -C $repo1 commit -m "initial spacing" - git -C $repo2 pull - - # repo1: change content but keep trailing spaces - printf "line1-changed\nline2 \nline3\n" > $repo1/spacefile - git -C $repo1 add spacefile - git -C $repo1 commit -m "content change" - - # repo2: remove trailing spaces but keep old content - printf "line1\nline2\nline3-changed\n" > $repo2/spacefile - git -C $repo2 add spacefile - git -C $repo2 commit -m "spacing change" - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_rebase_strategy_option $repo1 $src repo "ignore-space-change" > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - # verify the rebase succeeded and content is merged - grep "line1-changed" $repo1/spacefile - grep "line3-changed" $repo1/spacefile - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref -} - -it_can_put_with_rebase_multiple_strategy_options_string() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # create a file with spacing issues - printf "line1\nline2 \nline3\n" > $repo1/testfile - git -C $repo1 add testfile - git -C $repo1 commit -m "initial" - git -C $repo2 pull - - # repo1: modify line1 and clean up spacing on line2 - printf "line1-remote\nline2\nline3\n" > $repo1/testfile - git -C $repo1 add testfile - git -C $repo1 commit -m "remote changes" - - # repo2: modify line3 but keep spacing on line2 - printf "line1\nline2 \nline3-local\n" > $repo2/testfile - git -C $repo2 add testfile - git -C $repo2 commit -m "local changes" - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - # This uses both "theirs" and "ignore-space-change" - put_uri_with_rebase_multiple_options_string $repo1 $src repo > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - # Should have remote's line1 change - grep "line1-remote" $repo1/testfile - # Should have local's line3 change (non-conflicting) - grep "line3-local" $repo1/testfile - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref -} - -it_can_put_with_rebase_multiple_strategy_options_array() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # create a file with spacing issues - printf "line1\nline2 \nline3\n" > $repo1/testfile - git -C $repo1 add testfile - git -C $repo1 commit -m "initial" - git -C $repo2 pull - - # repo1: modify line1 and clean up spacing on line2 - printf "line1-remote\nline2\nline3\n" > $repo1/testfile - git -C $repo1 add testfile - git -C $repo1 commit -m "remote changes" - - # repo2: modify line3 but keep spacing on line2 - printf "line1\nline2 \nline3-local\n" > $repo2/testfile - git -C $repo2 add testfile - git -C $repo2 commit -m "local changes" - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - # This uses both "theirs" and "ignore-space-change" - put_uri_with_rebase_multiple_options_array $repo1 $src repo > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - # Should have remote's line1 change - grep "line1-remote" $repo1/testfile - # Should have local's line3 change (non-conflicting) - grep "line3-local" $repo1/testfile - test "$(git -C $repo1 rev-parse HEAD)" = $rebased_ref -} - -it_can_put_to_url_with_merge_commit() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # make a commit that will require rebasing - local baseref=$(make_commit_to_file $repo1 some-other-file) - - local ref=$(make_commit $repo2) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_merge $repo1 $src repo > $response - - local merged_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $merged_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - - test "$(git -C $repo1 rev-parse HEAD)" = $merged_ref - - local latest_merge_ref=$(git -C $repo1 log -n 1 --merges --pretty=format:"%H") - - test $latest_merge_ref = $merged_ref -} - -it_chooses_the_unmerged_commit_ref() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - # make a commit that will require rebasing - local baseref=$(make_commit_to_file $repo1 some-other-file) - - local unmerged_ref=$(make_commit $repo2) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_merge_returning_unmerged $repo1 $src repo > $response - - local merged_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $unmerged_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - - test "$(git -C $repo1 rev-parse HEAD)" = $merged_ref - - local latest_merge_ref=$(git -C $repo1 log -n 1 --merges --pretty=format:"%H") - - test $latest_merge_ref = $merged_ref -} - -it_will_fail_put_if_merge_and_rebase_are_set() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local expected_ref=$(make_commit $repo1) - local unpushable_ref=$(make_commit $repo2) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local result=$(put_uri_with_merge_and_rebase $repo1 $src repo | jq -e " - .version == {ref: $(echo $unpushable_ref | jq -R .)} - " || false) - - # switch back to master - git -C $repo1 checkout master - - test "$(git -C $repo1 rev-parse HEAD)" = $expected_ref -} - -it_can_put_to_url_with_only_tag() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # create a tag to push - git -C $repo2 tag some-only-tag - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_only_tag $repo1 $src repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test ! -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" != $ref - test "$(git -C $repo1 rev-parse some-only-tag)" = $ref -} - -it_can_put_to_url_with_notes() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - echo some-notes > $src/notes-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_notes $repo1 $src notes-file repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - and - (.metadata | .[] | select(.name == \"branch\") | .value == $(echo master | jq -R .)) - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - test "$(git -C $repo1 notes show)" = some-notes -} - -it_can_put_to_url_with_rebase_with_notes() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - echo some-notes > $src/notes-file - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local response=$(mktemp $TMPDIR/rebased-response.XXXXXX) - - put_uri_with_rebase_with_notes $repo1 $src notes-file repo > $response - - local rebased_ref=$(git -C $repo2 rev-parse HEAD) - - jq -e " - .version == {ref: $(echo $rebased_ref | jq -R .)} - " < $response - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - test "$(git -C $repo1 notes show)" = some-notes -} - -it_can_put_and_set_git_config() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # create a tag to push - git -C $repo2 tag some-tag - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - cp ~/.gitconfig ~/.gitconfig.orig - - put_uri_with_config $repo1 $src repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test "$(git config --global core.pager)" == 'true' - test "$(git config --global credential.helper)" == '!true long command with variables $@' - - mv ~/.gitconfig.orig ~/.gitconfig -} - -it_will_fail_put_if_conflicts_and_not_force_push() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local expected_ref=$(make_commit $repo1) - local unpushable_ref=$(make_commit $repo2) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local result=$(put_uri $repo1 $src repo | jq -e " - .version == {ref: $(echo $unpushable_ref | jq -R .)} - " || false) - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $expected_ref - test "$(git -C $repo1 log --name-only | grep $unpushable_ref)" = '' -} - -it_can_put_and_force_the_push() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - local lostref=$(make_commit $repo1) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_force $repo1 $src repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - test "$(git -C $repo1 log --name-only | grep $lostref)" = '' -} - -it_can_put_to_url_with_only_tag_and_force_the_push() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # create a tag in the upstream branch - git -C $repo1 tag some-only-tag - - # create the same tag to push upstream - git -C $repo2 tag some-only-tag - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_only_tag_with_force $repo1 $src repo | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test ! -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" != $ref - test "$(git -C $repo1 rev-parse some-only-tag)" = $ref -} - -it_will_fail_put_with_conflicting_tag_and_not_force_push() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local expected_ref=$(make_commit $repo1) - local unpushable_ref=$(make_commit $repo2) - - # create a tag in the upstream branch - git -C $repo1 tag some-only-tag - - # create the same tag to push upstream - git -C $repo2 tag some-only-tag - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - local result=$(put_uri_with_only_tag $repo1 $src repo | jq -e " - .version == {ref: $(echo $unpushable_ref | jq -R .)} - " || false) - - # switch back to master - git -C $repo1 checkout master - - test "$(git -C $repo1 rev-parse HEAD)" = $expected_ref - test "$(git -C $repo1 rev-parse some-only-tag)" = $expected_ref -} - -it_can_put_with_refs_prefix() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - set -x - put_uri_with_refs_prefix $repo1 $src repo refs/for | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout refs/for/master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref -} - -it_can_put_to_url_with_push_options() { - local repo1=$(init_repo) - - local src=$(mktemp -d $TMPDIR/put-src.XXXXXX) - local repo2=$src/repo - git clone $repo1 $repo2 - - local ref=$(make_commit $repo2) - - # enable push options on the remote repo - git -C $repo1 config receive.advertisePushOptions true - - # install a pre-receive hook that captures push options - local push_options_file=$(mktemp $TMPDIR/push-options.XXXXXX) - cat > $repo1/.git/hooks/pre-receive < $push_options_file -cat <&0 > /dev/null -HOOK - chmod +x $repo1/.git/hooks/pre-receive - - # cannot push to repo while it's checked out to a branch - git -C $repo1 checkout refs/heads/master - - put_uri_with_push_options $repo1 $src repo '["option-1", "option-2"]' | jq -e " - .version == {ref: $(echo $ref | jq -R .)} - " - - # switch back to master - git -C $repo1 checkout master - - test -e $repo1/some-file - test "$(git -C $repo1 rev-parse HEAD)" = $ref - - # verify push options were received - grep "GIT_PUSH_OPTION_0=option-1" $push_options_file - grep "GIT_PUSH_OPTION_1=option-2" $push_options_file -} - -it_errors_when_there_are_unknown_keys_in_params() { - local failed_output=$TMPDIR/put-unknown-keys-output - if put_uri_unknown_keys "some-uri" "some-dest" "some-repo" 2>"$failed_output"; then - echo "put should have failed" - return 1 - fi - - grep "Found unknown keys in put params:" "$failed_output" - grep "unknown_key" "$failed_output" - grep "other_key" "$failed_output" -} - -run it_can_put_to_url -run it_can_put_to_url_with_branch -run it_returns_branch_in_metadata -run it_can_put_to_url_with_tag -run it_can_put_to_url_with_tag_and_prefix -run it_can_put_to_url_with_tag_and_annotation -run it_can_put_to_url_with_notes -run it_can_put_to_url_with_rebase_with_notes -run it_can_put_to_url_with_rebase -run it_can_put_to_url_with_rebase_with_tag -run it_can_put_to_url_with_rebase_with_tag_and_prefix -run it_can_put_to_url_with_rebase_strategy_options -run it_can_put_with_rebase_ignore_space_change -run it_can_put_with_rebase_multiple_strategy_options_string -run it_can_put_with_rebase_multiple_strategy_options_array -run it_will_fail_put_if_merge_and_rebase_are_set -run it_can_put_to_url_with_merge_commit -run it_chooses_the_unmerged_commit_ref -run it_can_put_to_url_with_only_tag -run it_can_put_and_set_git_config -run it_will_fail_put_if_conflicts_and_not_force_push -run it_can_put_and_force_the_push -run it_can_put_to_url_with_only_tag_and_force_the_push -run it_will_fail_put_with_conflicting_tag_and_not_force_push -run it_can_put_with_refs_prefix -run it_can_put_to_url_with_push_options -run it_errors_when_there_are_unknown_keys_in_params diff --git a/version b/version new file mode 100644 index 00000000..f9e8384b --- /dev/null +++ b/version @@ -0,0 +1 @@ +1.24.1