Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ By default, the Step performs a shallow clone in most cases (fetching only the l

## 🧩 Get started

Add this step directly to your workflow in the [Bitrise Workflow Editor](https://devcenter.bitrise.io/steps-and-workflows/steps-and-workflows-index/).
Add this step directly to your workflow in the [Bitrise Workflow Editor](https://docs.bitrise.io/en/bitrise-ci/workflows-and-pipelines/steps/adding-steps-to-a-workflow.html).

You can also run this step directly with [Bitrise CLI](https://github.com/bitrise-io/bitrise).

Expand All @@ -50,6 +50,8 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris
| Key | Description | Flags | Default |
| --- | --- | --- | --- |
| `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` |
| `git_http_username` | Username for establishing an HTTP(S) connection to the repository. This is typically required when the repository is private. | sensitive | `$GIT_HTTP_USERNAME` |
| `git_http_password` | Personal access token (or password) for establishing an HTTP(S) connection to the repository. This is typically required when the repository is private. | sensitive | `$GIT_HTTP_PASSWORD` |
| `clone_into_dir` | Local directory where the repository is cloned | required | `$BITRISE_SOURCE_DIR` |
| `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. | | |
| `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` |
Expand All @@ -66,10 +68,9 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris
| `pull_request_unverified_merge_branch` | This input is the same as **Pull request merge ref**, but the provided merge ref can be potentially outdated. The Step will make an attempt to check it's validity and only use it for the checkout if it's up-to-date with the PR head. | | `$BITRISEIO_PULL_REQUEST_UNVERIFIED_MERGE_BRANCH` |
| `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` |
| `reset_repository` | Reset repository contents with `git reset --hard HEAD` and `git clean -f` before fetching. | | `No` |
| `performance_monitoring` | Prints extra performance related information for every git operation. | | `no` |
| `build_url` | Unique build URL of this build on Bitrise.io | | `$BITRISE_BUILD_URL` |
| `build_api_token` | The build's API Token for the build on Bitrise.io | sensitive | `$BITRISE_BUILD_API_TOKEN` |
| `git_http_username` | Username for establishing an HTTP(S) connection to the repository | sensitive | `$GIT_HTTP_USERNAME` |
| `git_http_password` | Personal access token (or password) for establishing an HTTP(S) connection to the repository | sensitive | `$GIT_HTTP_PASSWORD` |
</details>

<details>
Expand All @@ -91,9 +92,10 @@ You can also run this step directly with [Bitrise CLI](https://github.com/bitris

We welcome [pull requests](https://github.com/bitrise-steplib/steps-git-clone/pulls) and [issues](https://github.com/bitrise-steplib/steps-git-clone/issues) against this repository.

For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://devcenter.bitrise.io/bitrise-cli/run-your-first-build/).
For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://docs.bitrise.io/en/bitrise-ci/bitrise-cli/running-your-first-local-build-with-the-cli.html).

Note: this step's end-to-end tests (defined in e2e/bitrise.yml) are working with secrets which are intentionally not stored in this repo. External contributors won't be able to run those tests. Don't worry, if you open a PR with your contribution, we will help with running tests and make sure that they pass.

Learn more about developing steps:

- [Create your own step](https://devcenter.bitrise.io/contributors/create-your-own-step/)
- [Testing your Step](https://devcenter.bitrise.io/contributors/testing-and-versioning-your-steps/)
- [Create your own step](https://docs.bitrise.io/en/bitrise-ci/workflows-and-pipelines/developing-your-own-bitrise-step/developing-a-new-step.html)
5 changes: 4 additions & 1 deletion bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ workflows:

generate_readme:
steps:
- git::https://github.com/bitrise-steplib/steps-readme-generator.git@main: { }
- git::https://github.com/bitrise-steplib/steps-readme-generator.git@main:
inputs:
- contrib_section: docs/contribution.md
- example_section: docs/examples.md
1 change: 1 addition & 0 deletions docs/contribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Note: this step's end-to-end tests (defined in e2e/bitrise.yml) are working with secrets which are intentionally not stored in this repo. External contributors won't be able to run those tests. Don't worry, if you open a PR with your contribution, we will help with running tests and make sure that they pass.
Empty file added docs/examples.md
Empty file.
4 changes: 2 additions & 2 deletions gitclone/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package gitclone
import (
"fmt"
"path/filepath"
"slices"
"strings"

"github.com/bitrise-io/go-utils/command/git"
"github.com/bitrise-io/go-utils/pathutil"
"github.com/bitrise-io/go-utils/sliceutil"
)

const (
Expand Down Expand Up @@ -193,7 +193,7 @@ func handleCheckoutError(callback getAvailableBranches, tag string, err error, s
branches := branchesByRemote[originRemoteName]
// There was no error grabbing the available branches
// And the current branch is not present in the list
if branchesErr == nil && !sliceutil.IsStringInSlice(branch, branches) {
if branchesErr == nil && !slices.Contains(branches, branch) {
return newStepErrorWithBranchRecommendations(
tag,
err,
Expand Down
8 changes: 8 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,20 @@ inputs:
- git_http_username: $GIT_HTTP_USERNAME
opts:
title: Username for establishing an HTTP(S) connection to the repository
description: |-
Username for establishing an HTTP(S) connection to the repository.

This is typically required when the repository is private.
is_dont_change_value: true
is_sensitive: true

- git_http_password: $GIT_HTTP_PASSWORD
opts:
title: Personal access token (or password) for establishing an HTTP(S) connection to the repository
description: |-
Personal access token (or password) for establishing an HTTP(S) connection to the repository.

This is typically required when the repository is private.
is_dont_change_value: true
is_sensitive: true

Expand Down