Skip to content

Commit 5150630

Browse files
authored
Revert "Revert to 6.2.2 (#203)" (#204)
This reverts commit b1bf5cb.
1 parent b1bf5cb commit 5150630

File tree

278 files changed

+87673
-4029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+87673
-4029
lines changed

README.md

+41-45
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,37 @@
22

33
[![Step changelog](https://shields.io/github/v/release/bitrise-steplib/steps-git-clone?include_prereleases&label=changelog&color=blueviolet)](https://github.com/bitrise-steplib/steps-git-clone/releases)
44

5-
The Step checks out the defined repository state, optionally updates the repository submodules and exports the achieved git repository state properties.
5+
Checks out the repository, updates submodules and exports git metadata as Step outputs.
66

77
<details>
88
<summary>Description</summary>
99

10-
The checkout process depends on the checkout properties: the Step either checks out a repository state defined by a git commit or a git tag, or achieves a merged state of a pull / merge request.
11-
The Step uses two solutions to achieve the merged state of the pull / merge request: auto merge in the case of a merge branch or diff file (provided by the Git service) and manual merge otherwise.
12-
Once the desired state is checked out, the Step optionally updates the submodules. In the case of pull / merge request, the Step checks out a detach head and exports the achieved git state properties.
10+
The checkout process depends on the Step settings and the build trigger parameters (coming from your git server).
11+
12+
Depending on the conditions, the step can checkout:
13+
- the merged state of a Pull Request
14+
- the head of a Pull Request
15+
- a git tag
16+
- a specific commit on a branch
17+
- the head of a branch
18+
19+
The Step also supports more advanced features, such as updating submodules and sparse checkouts.
1320

1421
### Configuring the Step
1522

16-
1. The **Git repository URL** and the ** Clone destination (local)directory path** fields are required fields and are automatically filled out based on your project settings.
17-
Optionally, you can modify the following fields in the **Clone Config** section:
18-
1. You can set the **Update the registered submodules?** option to `yes` to pull the most up-to-date version of the submodule from the submodule's repository.
19-
2. You can set the number of commits you want the Step to fetch in the **Limit fetching to the specified number of commits** option. Make sure you set a decimal number.
23+
The step should work with its default configuration if build triggers and webhooks are set up correctly.
2024

21-
Other **Clone config** inputs are not editable unless you go to the **bitrise.yml** tab, however, to avoid issues, we suggest you to contact our Support team instead.
25+
By default, the Step performs a shallow clone in most cases (fetching only the latest commit) to make the clone fast and efficient. If your workflow requires a deeper commit history, you can override this using the **Clone depth** input.
2226

23-
### Troubleshooting
24-
If you have GitHub Enterprise set up, it works slightly differently on [bitrise.io](https://www.bitrise.io) than on [github.com](https://github.com). You have to manually set the git clone URL, register the SSH key and the webhook.
25-
If you face network issues in the case of self-hosted git servers, we advise you to contact our Support Team to help you out.
26-
If you face slow clone speed, set the **Limit fetching to the specified number of commits** to the number of commits you want to clone instead of cloning the whole commit history or you can use the Git LFS solution provided by the git provider.
27-
2827
### Useful links
2928

3029
- [How to register a GitHub Enterprise repository](https://discuss.bitrise.io/t/how-to-register-a-github-enterprise-repository/218)
3130
- [Code security](https://devcenter.bitrise.io/getting-started/code-security/)
3231

3332
### Related Steps
34-
33+
3534
- [Activate SSH key (RSA private key)](https://www.bitrise.io/integrations/steps/activate-ssh-key)
36-
- [Bitrise.io Cache:Pull](https://www.bitrise.io/integrations/steps/cache-pull)
37-
- [Bitrise.io Cache:Push](https://www.bitrise.io/integrations/steps/cache-push)
35+
- [Generate changelog](https://bitrise.io/integrations/steps/generate-changelog)
3836

3937
</details>
4038

@@ -51,41 +49,39 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris
5149

5250
| Key | Description | Flags | Default |
5351
| --- | --- | --- | --- |
54-
| `repository_url` | | required | `$GIT_REPOSITORY_URL` |
55-
| `clone_into_dir` | | required | `$BITRISE_SOURCE_DIR` |
56-
| `commit` | | | `$BITRISE_GIT_COMMIT` |
57-
| `tag` | | | `$BITRISE_GIT_TAG` |
58-
| `branch` | | | `$BITRISE_GIT_BRANCH` |
59-
| `branch_dest` | | | `$BITRISEIO_GIT_BRANCH_DEST` |
60-
| `pull_request_id` | | | `$PULL_REQUEST_ID` |
61-
| `pull_request_repository_url` | | | `$BITRISEIO_PULL_REQUEST_REPOSITORY_URL` |
62-
| `pull_request_merge_branch` | | | `$BITRISEIO_PULL_REQUEST_MERGE_BRANCH` |
63-
| `pull_request_head_branch` | If the Git hosting provider system supports and provides this, this special git ref should point to the source of the pull request. | | `$BITRISEIO_PULL_REQUEST_HEAD_BRANCH` |
64-
| `update_submodules` | Update the registered submodules to match what the superproject expects by cloning missing submodules, fetching missing commits in submodules and updating the working tree of the submodules. If set to "no" `git fetch` calls will get the `--no-recurse-submodules` flag. | | `yes` |
65-
| `clone_depth` | Limit fetching to the specified number of commits. The value should be a decimal number, for example `10`. | | |
66-
| `submodule_update_depth` | Truncate the history to the specified number of revisions. The value should be a decimal number, for example `10`. | | |
67-
| `merge_pr` | Disables merging the source and destination branches. - `yes`: The default setting. Merges the source branch into the destination branch. - `no`: Treats Pull Request events as Push events on the source branch. | | `yes` |
68-
| `sparse_directories` | Limit which directories should be cloned during the build. This could be useful if a repository contains multiple platforms, so called monorepositories, and the build is only targeting a single platform. For example, specifying "src/android" the Step will only clone: - contents of the root directory and - contents of the "src/android" directory and all subdirectories of "src/android". On the other hand, "src/ios" and any other directories will not be cloned. | | |
69-
| `reset_repository` | | | `No` |
70-
| `manual_merge` | Prefer to do a manual `git merge` by default. When the Pull Request is from a GitHub or Bitbucket private fork repository set this to `no`. | | `yes` |
71-
| `fetch_tags` | yes - fetch all tags from the remote by adding `--tags` flag to git fetch calls no - disable automatic tag following by adding `--no-tags` flag to git fetch calls | | `no` |
52+
| `merge_pr` | This only applies to builds triggered by pull requests. Options: - `yes`: Depending on the information in the build trigger, either fetches the PR merge ref or creates the merged state locally. - `no`: Checks out the head of the PR branch without merging it into the destination branch. | | `yes` |
53+
| `clone_into_dir` | Local directory where the repository is cloned | required | `$BITRISE_SOURCE_DIR` |
54+
| `clone_depth` | Limit fetching to the specified number of commits. By default, the Step tries to do a shallow clone (depth of 1) if it's possible based on the build trigger parameters. If it's not possible, it applies a low depth value, unless another value is specified here. It's not recommended to define this input because a shallow clone ensures fast clone times. Examples of when you want to override the clone depth: - A Step in the workflow reads the commit history in order to generate a changelog - A Step in the workflow runs a git diff against a previous commit Use the value `-1` to disable the depth limit completely and fetch the entire repo history. | | |
55+
| `update_submodules` | Update registered submodules to match what the superproject expects. If set to `no`, `git fetch` calls will use the `--no-recurse-submodules` flag. | | `yes` |
56+
| `submodule_update_depth` | When updating submodules, limit fetching to the specified number of commits. The value should be a decimal number, for example `10`. | | |
57+
| `fetch_tags` | yes - fetch all tags from the remote by adding `--tags` flag to `git fetch` calls no - disable automatic tag following by adding `--no-tags` flag to `git fetch` calls | | `no` |
58+
| `sparse_directories` | Limit which directories to clone using [sparse-checkout](https://git-scm.com/docs/git-sparse-checkout). This is useful for monorepos where the current workflow only needs a subfolder. For example, specifying `src/android` the Step will only clone: - contents of the root directory and - contents of the `src/android` directory and all of its subdirectories On the other hand, `src/ios` will not be cloned. This input accepts one path per line, separate entries by a linebreak. | | |
59+
| `repository_url` | SSH or HTTPS URL of the repository to clone | required | `$GIT_REPOSITORY_URL` |
60+
| `commit` | Commit SHA to checkout | | `$BITRISE_GIT_COMMIT` |
61+
| `tag` | Git tag to checkout | | `$BITRISE_GIT_TAG` |
62+
| `branch` | Git branch to checkout | | `$BITRISE_GIT_BRANCH` |
63+
| `branch_dest` | The branch that the pull request targets, such as `main` | | `$BITRISEIO_GIT_BRANCH_DEST` |
64+
| `pull_request_repository_url` | URL of the source repository of a pull request. This points to the fork repository in builds triggered by pull requests. | | `$BITRISEIO_PULL_REQUEST_REPOSITORY_URL` |
65+
| `pull_request_merge_branch` | Git ref pointing to the result of merging the PR branch into the destination branch. Even if the source of the PR is a fork, this is a reference to the destination repository. Example: `refs/pull/14/merge` Note: not all Git services provide this value. | | `$BITRISEIO_PULL_REQUEST_MERGE_BRANCH` |
66+
| `pull_request_head_branch` | Git ref pointing to the head of the PR branch. Even if the source of the PR is a fork, this is a reference to the destination repository. Example: `refs/pull/14/head` Note: not all Git services provide this value. | | `$BITRISEIO_PULL_REQUEST_HEAD_BRANCH` |
67+
| `reset_repository` | Reset repository contents with `git reset --hard HEAD` and `git clean -f` before fetching. | | `No` |
7268
| `build_url` | Unique build URL of this build on Bitrise.io | | `$BITRISE_BUILD_URL` |
7369
| `build_api_token` | The build's API Token for the build on Bitrise.io | sensitive | `$BITRISE_BUILD_API_TOKEN` |
7470
</details>
7571

7672
<details>
7773
<summary>Outputs</summary>
7874

79-
| Environment Variable | Description |
80-
|------------------------------------| --- |
81-
| `GIT_CLONE_COMMIT_HASH` | |
82-
| `GIT_CLONE_COMMIT_MESSAGE_SUBJECT` | |
83-
| `GIT_CLONE_COMMIT_MESSAGE_BODY` | |
84-
| `GIT_CLONE_COMMIT_COUNT` | Count will only work properly if no `--depth` option is set. If `--depth` is set then the history truncated to the specified number of commits. Count will **not** fail but will be the clone depth. |
85-
| `GIT_CLONE_COMMIT_AUTHOR_NAME` | |
86-
| `GIT_CLONE_COMMIT_AUTHOR_EMAIL` | |
87-
| `GIT_CLONE_COMMIT_COMMITTER_NAME` | |
88-
| `GIT_CLONE_COMMIT_COMMITTER_EMAIL` | |
75+
| Environment Variable | Description |
76+
| --- | --- |
77+
| `GIT_CLONE_COMMIT_HASH` | SHA hash of the checked-out commit. |
78+
| `GIT_CLONE_COMMIT_MESSAGE_SUBJECT` | Commit message of the checked-out commit. |
79+
| `GIT_CLONE_COMMIT_MESSAGE_BODY` | Commit message body of the checked-out commit. |
80+
| `GIT_CLONE_COMMIT_COUNT` | Commit count after checkout. Count will only work properly if no `--depth` option is set. If `--depth` is set then the history truncated to the specified number of commits. Count will **not** fail but will be the clone depth. |
81+
| `GIT_CLONE_COMMIT_AUTHOR_NAME` | Author of the checked-out commit. |
82+
| `GIT_CLONE_COMMIT_AUTHOR_EMAIL` | Email of the checked-out commit. |
83+
| `GIT_CLONE_COMMIT_COMMITTER_NAME` | Committer name of the checked-out commit. |
84+
| `GIT_CLONE_COMMIT_COMMITTER_EMAIL` | Email of the checked-out commit. |
8985
</details>
9086

9187
## 🙋 Contributing

e2e/bitrise.yml

+13-48
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ app:
1010
- MERGE_PR: "yes"
1111
- CLONE_DEPTH: ""
1212
- SPARSE_DIRECTORIES: ""
13-
- MANUAL_MERGE: "yes"
1413
# define these envs in your .bitrise.secrets.yml
1514
- GIT_CLONE_SSH_PRIVATE_KEY: $GIT_CLONE_SSH_PRIVATE_KEY
1615

@@ -22,6 +21,7 @@ workflows:
2221
- BRANCH: test/generate-changelog
2322
- FETCH_TAGS: "yes"
2423
- UPDATE_SUBMODULES: "no"
24+
- CLONE_DEPTH: 78
2525
before_run:
2626
- _setup
2727
after_run:
@@ -36,6 +36,7 @@ workflows:
3636
- BRANCH: test/generate-changelog
3737
- FETCH_TAGS: "yes"
3838
- UPDATE_SUBMODULES: "no"
39+
- CLONE_DEPTH: 46
3940
before_run:
4041
- _setup
4142
after_run:
@@ -184,11 +185,9 @@ workflows:
184185

185186
test_checkout_github_pull_request:
186187
envs:
187-
- PULL_REQUEST_ID: 5
188188
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/5/merge
189189
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/5/head
190190
- BITRISEIO_GIT_BRANCH_DEST: master
191-
- MANUAL_MERGE: "no"
192191
- UPDATE_SUBMODULES: "no"
193192
before_run:
194193
- _setup
@@ -199,12 +198,11 @@ workflows:
199198

200199
test_checkout_pull_request_no_merge:
201200
envs:
202-
- PULL_REQUEST_ID: 5
203201
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/5/merge
204202
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/5/head
205203
- BITRISEIO_GIT_BRANCH_DEST: master
206204
- COMMIT: 4301a9b8499ed3e87778dd053c55fd698d0a3b7e
207-
- MANUAL_MERGE: "no"
205+
- CLONE_DEPTH: 1
208206
- MERGE_PR: "no"
209207
- UPDATE_SUBMODULES: "no"
210208
before_run:
@@ -214,44 +212,12 @@ workflows:
214212
- _check_outputs
215213
- _teardown
216214

217-
test_checkout_pull_request_standard_branch:
218-
envs:
219-
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pr_test
220-
- BITRISEIO_GIT_BRANCH_DEST: master
221-
- MANUAL_MERGE: "no"
222-
- UPDATE_SUBMODULES: "no"
223-
before_run:
224-
- _setup
225-
after_run:
226-
- _run
227-
- _check_outputs
228-
- _teardown
229-
230215
test_checkout_pull_request_with_depth:
231216
envs:
232-
- PULL_REQUEST_ID: 5
233217
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/5/merge
234218
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/5/head
235219
- BITRISEIO_GIT_BRANCH_DEST: master
236220
- CLONE_DEPTH: 1
237-
- MANUAL_MERGE: "no"
238-
before_run:
239-
- _setup
240-
after_run:
241-
- _run
242-
- _check_outputs
243-
- _teardown
244-
245-
test_manual_merge_unshallow:
246-
envs:
247-
- PULL_REQUEST_ID: 5
248-
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/7/merge
249-
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/7/head
250-
- BITRISEIO_GIT_BRANCH_DEST: master
251-
- COMMIT: 76a934ae80f12bb9b504bbc86f64a1d310e5db64
252-
- BRANCH: test/commit-messages
253-
- CLONE_DEPTH: 1
254-
- UPDATE_SUBMODULES: "no"
255221
before_run:
256222
- _setup
257223
after_run:
@@ -300,9 +266,9 @@ workflows:
300266

301267
test_hosted_git_notfork:
302268
envs:
303-
- PULL_REQUEST_ID: 7
304269
- BITRISEIO_PULL_REQUEST_REPOSITORY_URL: [email protected]:bitrise-io/git-clone-test.git
305270
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/7/merge
271+
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/7/head
306272
- BITRISEIO_GIT_BRANCH_DEST: master
307273
- COMMIT: 76a934ae80f12bb9b504bbc86f64a1d310e5db64
308274
- BRANCH: test/commit-messages
@@ -329,15 +295,13 @@ workflows:
329295

330296
test_fork_with_head_branch:
331297
envs:
332-
- PULL_REQUEST_ID: 7
333298
# Alternate URL for repository, the difference causes the Step to handle it as a fork
334299
- BITRISEIO_PULL_REQUEST_REPOSITORY_URL: https://github.com/bitrise-samples/git-clone-test/
335300
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/7/merge
336301
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/7/head
337302
- BITRISEIO_GIT_BRANCH_DEST: master
338303
- COMMIT: 76a934ae80f12bb9b504bbc86f64a1d310e5db64
339304
- BRANCH: test/commit-messages
340-
- MANUAL_MERGE: "no"
341305
before_run:
342306
- _setup
343307
after_run:
@@ -347,13 +311,12 @@ workflows:
347311

348312
test_unrelated_histories:
349313
envs:
350-
- PULL_REQUEST_ID: 8
351314
- BITRISEIO_PULL_REQUEST_MERGE_BRANCH: pull/8/merge
315+
- BITRISEIO_PULL_REQUEST_HEAD_BRANCH: pull/8/head
352316
- BITRISEIO_PULL_REQUEST_REPOSITORY_URL: $TEST_REPO_URL
353317
- BITRISEIO_GIT_BRANCH_DEST: unrelated-histories/master
354318
- COMMIT: 62af44590c7a2b937726f2c3024a88a129b330b5
355319
- CLONE_DEPTH: 1
356-
- MANUAL_MERGE: "no"
357320
- UPDATE_SUBMODULES: "no"
358321
before_run:
359322
- _setup
@@ -416,13 +379,11 @@ workflows:
416379
inputs:
417380
- repository_url: $TEST_DIFF_REPO_URL
418381
- clone_into_dir: $TEST_DIFF_CLONE_DIR
419-
- pull_request_id: 8
420382
- pull_request_repository_url: $TEST_DIFF_PR_REPOSITORY_URL
421383
- branch_dest: master
422384
- branch: master
423385
- commit: c6810e6
424386
- clone_depth: 1
425-
- manual_merge: "no"
426387
- script:
427388
inputs:
428389
- content: |-
@@ -492,7 +453,7 @@ workflows:
492453
inputs:
493454
- content: |-
494455
#!/bin/env bash
495-
set -ex
456+
set -e
496457
497458
EXPECTED_CHANGELOG="* [a409478] Add newline to the description.
498459
* [b002ab7] Add repository description.
@@ -503,6 +464,11 @@ workflows:
503464
echo "Expected changelog generated."
504465
else
505466
echo "Invalid changelog generated:"
467+
echo ""
468+
echo "Expected changelog:"
469+
echo "$EXPECTED_CHANGELOG"
470+
echo ""
471+
echo "Generated changelog:"
506472
echo "$BITRISE_CHANGELOG"
507473
exit 1
508474
fi
@@ -526,7 +492,7 @@ workflows:
526492
check "GIT_CLONE_COMMIT_HASH" "76a934ae80f12bb9b504bbc86f64a1d310e5db64"
527493
check "GIT_CLONE_COMMIT_MESSAGE_SUBJECT" "Sample commit message subject"
528494
check "GIT_CLONE_COMMIT_MESSAGE_BODY" "Sample commit message body"
529-
check "GIT_CLONE_COMMIT_COUNT" "25"
495+
check "GIT_CLONE_COMMIT_COUNT" "1"
530496
check "GIT_CLONE_COMMIT_AUTHOR_NAME" "Krisztian Dobmayer"
531497
check "GIT_CLONE_COMMIT_AUTHOR_EMAIL" "[email protected]"
532498
check "GIT_CLONE_COMMIT_COMMITTER_NAME" "Krisztian Dobmayer"
@@ -578,7 +544,6 @@ workflows:
578544
envman unset --key BITRISE_GIT_TAG
579545
envman unset --key BITRISE_GIT_BRANCH
580546
envman unset --key BITRISEIO_GIT_BRANCH_DEST
581-
envman unset --key PULL_REQUEST_ID
582547
envman unset --key BITRISEIO_PULL_REQUEST_REPOSITORY_URL
583548
envman unset --key BITRISEIO_PULL_REQUEST_MERGE_BRANCH
584549
envman unset --key BITRISEIO_PULL_REQUEST_HEAD_BRANCH
@@ -614,6 +579,7 @@ workflows:
614579
envman add --key WORKDIR_ABSOLUTE --value $WD
615580
fi
616581
- path::./:
582+
run_if: "true"
617583
inputs:
618584
- repository_url: $TEST_REPO_URL
619585
- clone_into_dir: $WORKDIR
@@ -625,7 +591,6 @@ workflows:
625591
- merge_pr: $MERGE_PR
626592
- clone_depth: $CLONE_DEPTH
627593
- sparse_directories: $SPARSE_DIRECTORIES
628-
- manual_merge: $MANUAL_MERGE
629594

630595
_teardown:
631596
steps:

0 commit comments

Comments
 (0)