A production-ready multi-threaded CLI tool and GitHub Action that bulk-clones, mirrors and refreshes repositories from Gerrit servers and GitHub organisations or user accounts, with automatic API discovery. Designed for reliability, speed, and CI/CD compatibility.
This tool used to be gerrit-clone. The PyPI package and the command are now
source-clone.
source-cloneinstalls only thesource-clonecommand. Thegerrit-clonecommand belongs to the oldgerrit-clonepackage, which can stay installed beside it. To switch, runuv tool uninstall gerrit-clone && uv tool install source-clone.- Environment variables (
GERRIT_*,GERRIT_CLONE_TOKEN,OUTPUT_PATHand the rest), command options and Action inputs have not changed. - Names the tool writes into your trees and repositories keep the old name, so
trees an earlier release wrote keep working: the
.gerrit-clone/directory and thegerrit-clone.*git config keys. - The tool reads
~/.config/source-clone/first, then falls back to~/.config/gerrit-clone/. - Earlier releases remain on PyPI under the
gerrit-clonename.
- Automatic API Discovery: Discovers Gerrit API endpoints across different
server configurations (
/r,/gerrit,/infra, etc.) - Bulk Repository Discovery: Fetches all projects via Gerrit REST API with intelligent filtering
- Multi-threaded Cloning: Concurrent operations with auto-scaling thread
pools (Gerrit uses a conservative auto-default of at most 8 concurrent SSH
sessions to avoid server-side throttling; GitHub uses up to 64 with a 2x
multiplier; override either with
--threads) - Hierarchy Preservation: Maintains complete Gerrit project folder structure without flattening
- Working Copies or Full Mirrors: Clones working copies by default;
--mirrormakes bare mirrors (git clone --mirror) holding all refs, tags, and branches for complete repository backups - GitHub Mirroring: Mirror Gerrit repositories to GitHub organizations with automatic name transformation
- Robust Retry Logic: Exponential backoff with full jitter for transient network and server failures, including a small bounded retry for Gerrit SSH throttling that can surface as a transient "Permission denied" rejection
- SSH Integration: Full SSH agent, identity file, and config support
- CI/CD Ready: Non-interactive operation with structured JSON manifests
- Smart Filtering: Automatically excludes system repos and archived projects
- Rich Progress Display: Beautiful terminal progress bars with per-repo status tracking
- Comprehensive Logging: Structured logging with configurable verbosity levels
For one-time execution without installation:
uvx source-clone clone --host gerrit.example.orguv tool install source-clone
# The installed command is on PATH
source-clone clone --host gerrit.example.orggit clone https://github.com/lfreleng-actions/source-clone-action.git
cd source-clone-action
uv sync
uv run source-clone clone --host gerrit.example.orgThe tool provides five main commands:
clone: Clone all repositories from a Gerrit server or GitHub organisationrefresh: Refresh local content cloned from a Gerrit server or GitHubmirror: Mirror repositories from a Gerrit server to GitHubreset: Remove all repositories from a GitHub organizationconfig: Show effective configuration from all sources
Clone all active repositories from a Gerrit server:
source-clone clone --host gerrit.example.orgClone to a specific directory with custom thread count:
source-clone clone --host gerrit.example.org \
--output-path ./repositories \
--threads 8Clone with shallow depth and specific branch:
source-clone clone --host gerrit.example.org \
--depth 10 \
--branch main \
--threads 16Back up every ref, tag and branch as bare mirrors instead of working copies:
source-clone clone --host gerrit.example.org \
--mirror \
--output-path ./backupInclude archived repositories and use custom SSH key:
source-clone clone --host gerrit.example.org \
--include-archived \
--ssh-user myuser \
--ssh-identity-file ~/.ssh/gerrit_rsaThe clone command takes its destination from the first of these
sources that holds a value, highest precedence first:
--output-path- the
OUTPUT_PATHenvironment variable - the
GERRIT_PATH_PREFIXenvironment variable - the
GERRIT_OUTPUT_DIRenvironment variable - the
pathkey of a config file
An empty environment variable or a null config-file path counts as
unset, so the next source applies. When no source holds a value, or
the value that applies is empty or a spelling of . (. components and
slashes with no leading slash: ., ./, .//, ./., ././),
source-clone automatically creates an organized folder structure to
prevent naming conflicts when cloning from different sources. An
explicit --output-path . or --output-path "" gives that structure
even when a lower source names a path:
Gerrit sources:
# Clones to: ./gerrit.example.org/project-name
source-clone clone --host gerrit.example.org
# Strips port from output-path: ./gerrit.example.org/project-name
source-clone clone --host gerrit.example.org:29418GitHub sources (these need a token, even for public repositories:
pass --github-token or set SOURCE_CLONE_TOKEN, GERRIT_CLONE_TOKEN
or GITHUB_TOKEN):
# Clones to: ./github.com/myorg/repo-name
source-clone clone --host github.com/myorg
# GitHub Enterprise: ./github.enterprise.com/engineering/repo-name
source-clone clone --host github.enterprise.com/engineeringCustom path (no auto-structure):
# Clones directly to: ./my-repos/project-name
source-clone clone --host gerrit.example.org --output-path ./my-repos
# Clones directly to: $PWD/project-name (the tool keeps an absolute path
# as given, even when it names the current directory)
source-clone clone --host gerrit.example.org --output-path "$PWD"The tool uses any value that is not empty or a spelling of . exactly
as given. That includes .., names starting with a dot such as
.hidden, relative paths such as child/.. that lead back to the
current directory, and any absolute path.
This design prevents repository naming conflicts when running concurrent clone operations in the same directory (e.g., on GitHub Actions runners).
By default, clone makes working copies: an ordinary git clone of
each project, with its files checked out on the default branch (or the one
--branch names), ready to cd into, read, build or edit. --depth makes
them shallow.
With --mirror, clone uses git clone --mirror to make bare mirrors
instead, holding complete metadata from the remote repository:
- ✅ All branches (not just the default)
- ✅ All tags
- ✅ All refs and notes
- ✅ Complete commit history
- ❌ No working directory: you cannot browse or edit files in place
When to use --mirror:
- Creating complete backups
- Mirroring to other Git servers later
- Archival purposes
- CI/CD pipelines that only need repository metadata
GERRIT_MIRROR=true or mirror: true in a config file selects mirror mode
too, and --no-mirror asks for working copies explicitly.
Note: The --mirror flag is incompatible with --depth and --branch.
If you specify mirror mode along with these options, the tool ignores them with
a warning. For a GitHub source, the warning names --no-mirror.
The mirror command (Gerrit to GitHub) always clones bare mirrors, since it
pushes with git push --mirror.
The GitHub Action makes working copies by default too (mirror: false).
Set mirror: true for bare mirrors of every source, or mirror: auto to
mirror Gerrit sources and make working copies of GitHub sources. auto
tells them apart as the CLI does: the source-type input, else the
SOURCE_TYPE environment variable, else the host.
Release 4.0 changes what clone and the Action make by default:
cloneand the Action now make working copies, where earlier releases made bare mirrors (the Action'sautodefault mirrored Gerrit sources). To keep making bare mirrors, pass--mirror, setGERRIT_MIRROR=true, setmirror: truein the config file, or set the Action inputmirror: true.--depthand--branchnow take effect without--no-mirror.--no-mirroris still accepted.- Existing trees are not converted.
cloneover an existing tree refreshes each bare mirror it finds as a mirror, and makes working copies only of projects it clones for the first time. It prints one notice giving the number of bare mirrors it found: pass--mirrorto keep the tree mirrored, or delete them and clone again to get working copies. - The
mirrorcommand still clones bare mirrors, as before.
refresh finds both kinds of clone beneath the output path. A --mirror
clone is a bare repository, so it has no branch to pull: refresh
fetches every ref into it and prunes refs deleted upstream (unless
--no-prune). The branch options (--strategy, --auto-stash, --force,
--force-hard) apply to working copies, the default clone, only. Refresh
skips a bare repository with no fetch refspec that updates a ref, such as
one made by git clone --bare, and says why: fetching it would update
nothing. If the
command finds no repositories at all, it says so and exits with status 1
rather than reporting success.
Content filtering (--remove-files, --git-filter, --redact-secrets) is a
decision about a whole clone tree, and later runs keep to it. The first run
that filters writes the decision to .gerrit-clone/filter-policy.json at the
root of the tree; the directory keeps the old tool name, for compatibility.
Every later clone, refresh or mirror in that tree applies it, even
without the options: to repositories cloned later, to files that appear
upstream later, and to a repository you delete and clone again. Options add
to the decision; leaving one out never removes a filter. The file keeps each
--git-filter token as a SHA-256 digest only, so a run must pass those tokens
again. If a run lacks a project's tokens, refresh skips that
project, clone exits with a filtering failure, and mirror aborts the
whole batch before it pushes anything; each gives the number of tokens the
project needs. A file the tool cannot read stops the run.
Each clone, refresh and mirror manifest summarises that decision in a
content_filters block: the path of the intent file, and for each scope its
removal patterns, whether it redacts secrets, and the number of
--git-filter tokens it replaces. It never includes a token or a token's
digest, since manifests often end up as public CI artifacts. A tree without
filters reports "content_filters": null.
Each repository also records which filters rewrote it. Fetching would force
the original history back, filtered content included, so refresh copies each
mirror it filters, fetches and filters the copy, and publishes its refs only
when every step succeeds; a failure leaves the mirror unchanged. Refresh
treats a working copy it filters the same way. It fetches and
filters a copy, kept inside the checkout's git directory. The checkout takes
the result only when fetching and filtering succeed and the filtered history
extends what the checkout holds; otherwise it stays unchanged, with any stash
put back. Once it has taken the result as its remote-tracking branches, it
fast-forwards or rebases as a pull would, and a conflict there leaves it as a
conflicting pull does. clone filters each new working copy
through a copy too, without fetching again, so it keeps its remote-tracking
branches and later refreshes follow it. When the filters rewrite it, its
branch then moves to the filtered upstream (a clone of a single tag moves to
the filtered tag), its tags become exactly the filtered ones, and the tool
purges the unfiltered objects. When filtering a new working copy fails, the tool
deletes it, so no unfiltered checkout remains. A working copy that content
filtering rewrote in place, as earlier releases' clone --no-mirror did, has
lost the remote-tracking branch a refresh follows, and gets skipped. clone
over it refreshes it rather than replacing it, and skips it the same way, so
delete it first, then clone it again with the same filters: the new working
copy of a branch keeps its remote-tracking branch, and later refreshes follow
it.
Every remote of a filtered repository refuses pushes. A tree filtered before
the tree-level file existed gains one from these per-repository records on
its next run. Releases up to v2.2.4 recorded no filters at all, so refresh
skips any repository they filtered, whatever filters you pass, and asks you
to re-clone it, and mirror --overwrite leaves it out of the run rather
than cloning or pushing it: delete it yourself, then clone it again with the
filters it needs. The tool recognises one by the traces those releases left: the
commit map a git filter-repo rewrite leaves in the git directory, or a
branch tip committed by the file-removal fallback (Remove filtered files for platform sync).
A --dry-run applies no content filters and records nothing.
Refresh all repositories in the current directory:
source-clone refreshRefresh ONAP repositories in a specific directory:
source-clone refresh --output-path ~/repos/onapFetch only (don't merge changes):
source-clone refresh --output-path ~/onap --fetch-onlyUse 16 threads for faster refresh:
source-clone refresh --output-path ~/onap --threads 16Automatically stash uncommitted changes before refresh:
source-clone refresh --output-path ~/onap --auto-stashForce refresh (stash local changes, fix detached HEAD, restore feature-branch checkouts to the default branch):
source-clone refresh --output-path ~/onap --forceHard reset: make local content exactly match the remote, discarding local-only
commits and any divergence. This is the single, explicit way to force-reset
local content and is a strict superset of --force:
source-clone refresh --output-path ~/onap --force-hardNote:
--force-hardis destructive: it permanently discards local-only commits on the default branch. It leaves other local branches untouched.
Use rebase strategy instead of merge:
source-clone refresh --output-path ~/onap --strategy rebaseDry run to see what changes would occur:
source-clone refresh --output-path ~/onap --dry-runRefresh only the repositories cloned from Gerrit:
source-clone refresh --output-path ~/repos --gerrit-onlyBy default, refresh refreshes every repository under the path, wherever
it came from; --all-repos asks for that explicitly. With --gerrit-only,
the clone-manifest.json nearest above a repository, looking in its parent
directory first and then each ancestor, decides: a source_type of
gerrit makes it Gerrit, and github does not. When no manifest exists,
or refresh cannot parse the nearest one, or it records no recognised
source_type, refresh checks the remotes instead: a repository with any
remote on a Gerrit server counts as Gerrit. A remote counts when it uses SSH port
29418, when a label of its host is gerrit or review or starts with
gerrit- or review- (gerrit.onap.org, review.opendev.org), or when an
HTTP(S) URL's first path segment is r or gerrit. Remotes on
github.com, *.github.com, gitlab.com and bitbucket.org never count,
and a repository's name or the rest of its path never decides. refresh
looks only for the default manifest name, so it checks the remotes of a
tree cloned with a custom --manifest-filename. It reports the
repositories it skips as not Gerrit repositories.
Here's a complete example showing the refresh workflow:
# Refresh ONAP repositories with auto-stash and 16 threads
source-clone refresh \
--output-path ~/repos/onap \
--threads 16 \
--auto-stash \
--strategy mergeExpected Output:
🏷️ source-clone refresh version X.Y.Z
Refresh Configuration
Base Path: ~/repos/onap
Threads: 16
Mode: Pull (merge)
Prune: True
Timeout: 300s
Skip Conflicts: True
Auto Stash: True
Filter: All repos
Dry Run: False
Force: False
Recursive: True
🔍 Discovering Git repositories in ~/repos/onap
📂 Discovered 127 Git repositories
🔄 Refreshing 127 repositories with 16 threads
Refreshing repositories ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 127/127 • 0:02:15
Refresh Summary
────────────────────────────────────────────────────────────
Total Repositories: 127
Duration: 135.4s
Results:
✅ Successful: 115
✓ Up-to-date: 98
🔄 Updated: 17
❌ Failed: 2
⊘ Skipped: 8
⚠️ Conflicts: 2
Repositories Updated: 17
Total Files Changed: 156
Issues:
❌ ccsdk-apps-services: Network error during pull
⚠️ ccsdk-features-sdnr: Merge conflicts detected
📄 Manifest: ~/repos/onap/refresh-manifest.json
⚠️ 2 repositories failed to refresh
Key Features:
- Parallel Updates: Uses concurrent threads for fast updates
- Every Repository: Refreshes every repository under the path, whatever
its remote;
--gerrit-onlyrestricts it to those the clone manifest or the remote's host marks as cloned from Gerrit - Safe Defaults: Skips repositories with uncommitted changes by default
- Auto-Stash: Optionally stash and restore uncommitted changes
- Flexible Strategies: Support for merge (fast-forward) or rebase
- Detailed Reporting: JSON manifest with complete results
- Dry Run: Preview changes without applying them
- Single Checkouts: Point
--output-pathat one working copy's top level, and refresh lists its own log and manifest in that checkout's.git/info/exclude, keeping them out of its uncommitted changes
Mirror all repositories from Gerrit to a GitHub organization:
source-clone mirror --server gerrit.onap.org --org modeseven-onapMirror specific projects with hierarchical filtering:
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--output-path /tmp/modeseven-onap \
--projects "ccsdk, oom, cps"Use HTTP API for discovery and HTTPS for cloning (no SSH required):
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--discovery-method http \
--httpsInclude archived/read-only repositories:
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--include-archivedDelete and recreate existing GitHub repositories and overwrite local clones:
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--recreate \
--overwriteNote on Project Hierarchies: When specifying projects like ccsdk, all
sub-projects (e.g., ccsdk/apps, ccsdk/features) are automatically
included. GitHub repository names replace slashes with hyphens:
ccsdk/features/test becomes ccsdk-features-test.
GitHub Authentication: Set the GITHUB_TOKEN environment variable with a
personal access token that has the required permissions:
export GITHUB_TOKEN=github_pat_your_token_here
source-clone mirror --server gerrit.example.org --org your-orgToken Requirements:
- Classic Token: Scopes:
repo,delete_repo - Fine-grained Token: Permissions:
- Contents (Read and Write)
- Administration (Read and Write)
- Metadata (Read access, automatic)
Here's a complete example showing the full workflow with expected output:
# Set GitHub token (get from https://github.com/settings/tokens)
# Required scopes: repo, delete_repo
export GITHUB_TOKEN="github_pat_XXXXXXXX"
# Mirror specific projects with recreation
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--output-path /tmp/modeseven-onap \
--projects "ccsdk, oom, cps" \
--recreate \
--overwriteExpected Output:
🏷️ source-clone mirror version X.Y.Z
🔑 Authenticating with GitHub...
✓ Using specified organization: modeseven-onap
📋 Project filters: ccsdk, oom, cps
🌐 Connecting to Gerrit: gerrit.onap.org
🔍 Discovering projects on gerrit.onap.org [SSH]
✅ Found 393 projects to process
📦 Found 19 projects to mirror
🚀 Starting mirror operation...
✓ Manifest written to: /tmp/modeseven-onap/mirror-manifest.json
Mirror Summary
Total: 19
Succeeded: 19
Failed: 0
Skipped: 0
Duration: 231.9s
The --recreate flag deletes and recreates existing GitHub repositories for a
clean mirror. Use --overwrite to also re-clone from Gerrit. See the manifest
file for detailed per-repository results.
Remove all repositories from a GitHub organization (with safety prompts):
# By default, excludes automation PRs from counts
source-clone reset --org my-test-orgInclude automation PRs (dependabot, pre-commit.ci, etc.) in counts:
source-clone reset --org my-test-org --include-automation-prsCompare local Gerrit clone with remote GitHub before deletion:
source-clone reset --org my-test-org \
--output-path /tmp/gerrit-mirror \
--compareDelete immediately without confirmation (DANGEROUS!):
source-clone reset --org my-test-org --no-confirmThe reset command will:
- List all repositories in the organization with PR/issue counts
- Optionally compare with local Gerrit clone (
--compareflag) - Prompt for unique confirmation hash (unless
--no-confirm) - Permanently delete all repositories
Safety Features:
- Displays comprehensive table with repo names, open PRs, and open issues
- Excludes automation PRs by default (dependabot, pre-commit.ci, renovate, github-actions, allcontributors)
- Requires unique hash based on organization state (prevents accidental deletion)
- Optional local/remote synchronization comparison
- Clear warnings about data loss
GitHub Token Requirements:
The reset command requires a Classic Personal Access Token with the
following scopes:
repo(full control of private repositories)delete_repo(delete repositories)read:org(read organization data)
reset command because they may not provide the required repository
permissions (including deletion) across targeted repositories and
organizations. Use a classic Personal Access Token with the scopes below.
To create a classic token:
- Go to https://github.com/settings/tokens
- Click "Generate new token" → "Generate new token (classic)"
- Select the required scopes:
repo,delete_repo,read:org - Set a token expiry date
- Copy the token and set it as an environment variable:
export GITHUB_TOKEN="ghp_your_classic_token_here"
source-clone reset --org my-test-orgRequired:
--org TEXT: GitHub organization to reset (delete all repositories)
Optional:
--output-path DIRECTORY(alias--path): Local Gerrit clone folder hierarchy (default: current directory)--compare: Compare local Gerrit clone with remote GitHub repositories before deletion--github-token TEXT: GitHub personal access token (or useGITHUB_TOKENenv var)--include-automation-prs: Include automation PRs (dependabot, pre-commit.ci, etc.) in PR counts (default: excluded)--no-confirm: Skip confirmation prompt and delete immediately--verbose/-v: Enable verbose output
Note: By default, the tool excludes automation PRs from tools like dependabot, pre-commit.ci, renovate, github-actions, and allcontributors. Use
--include-automation-prsto include them.
Usage: source-clone clone [OPTIONS]
Options:
--host, -h TEXT Source hostname (Gerrit server or GitHub
URL like github.com/ORG) [required]
--org, --github-org TEXT GitHub organization or user name
-p, --port INTEGER Gerrit SSH port [default: 29418]
--base-url TEXT Base URL for Gerrit API
-u, --ssh-user TEXT SSH username for clone operations
-i, --ssh-identity-file PATH SSH identity (private key) file path
--output-path PATH Base directory for clone hierarchy
--skip-archived / --include-archived
Skip archived and inactive repositories
[default: skip-archived]
--include-projects, --include-project TEXT
Restrict cloning to specific project(s)
--exclude-projects, --exclude-project TEXT
Exclude project(s); supports wildcard and
hierarchical (path-style) matching
--include-projects-file FILE Read include patterns from a file; repeatable
--exclude-projects-file FILE Read exclude patterns from a file; repeatable
--discovery-method TEXT Method for discovering projects: ssh (default),
http (REST API), or both (union of both methods
with SSH metadata preferred)
--ssh-debug Enable verbose SSH (-vvv) for troubleshooting
--allow-nested-git / --no-allow-nested-git
Allow nested git working trees when cloning
both parent and child repositories
[default: allow-nested-git]
--nested-protection / --no-nested-protection
Auto-add nested child repo paths to parent
.git/info/exclude [default: nested-protection]
--move-conflicting / --no-move-conflicting
Move conflicting files/directories in parent
repos to [NAME].parent to allow nested cloning
-t, --threads INTEGER Number of concurrent clone threads
(auto-detected: 2x multiplier for GitHub sources)
-d, --depth INTEGER Create shallow clone with given depth
-b, --branch TEXT Clone specific branch instead of default
--https / --ssh Use HTTPS for cloning [default: ssh]
--keep-remote-protocol Keep original clone protocol for remote
--strict-host / --accept-unknown-host
SSH strict host key checking [default: strict-host]
--timeout, --clone-timeout INTEGER
Timeout per clone operation in seconds
[default: 600]
--retry-attempts INTEGER Max retry attempts per repository
[default: 3]
--retry-base-delay FLOAT Base delay for retry backoff in seconds
[default: 2.0]
--retry-factor FLOAT Exponential backoff factor [default: 2.0]
--retry-max-delay FLOAT Max retry delay in seconds [default: 30.0]
--manifest-filename TEXT Output manifest filename
[default: clone-manifest.json]
-c, --config-file PATH Configuration file path (YAML or JSON)
--cleanup / --no-cleanup Remove cloned repositories (path) after
run completes (success or failure),
keeping the run's log file
--exit-on-error Exit when first error occurs
--log-file PATH Custom log file path
--disable-log-file Disable creation of log file
--log-level TEXT File logging level [default: DEBUG]
-v, --verbose Enable verbose/debug output
-q, --quiet Suppress all output except errors
--version Show version information
--help Show this message and exit
--include-projects-file and --exclude-projects-file read patterns from
a file, one or more per line, separated by commas or spaces. A # starts a
comment that runs to the end of the line, and the tool skips blank lines.
The tool adds the file patterns after any --include-projects or
--exclude-projects patterns. A file that names no project is an error,
which keeps an empty list from widening a run to every project. The manifest's
config block records the effective include_projects and
exclude_projects lists.
# estate.txt
releng/*
ci-management # shared CI jobs
source-clone clone --host github.com/myorg --include-projects-file estate.txtDiscovery and Connection:
--host TEXT(alias--server): Gerrit server hostname (required)--port INTEGER: Gerrit SSH port (default: 29418)--ssh-user TEXT/-u: SSH username for Gerrit clone operations (env:GERRIT_SSH_USER)--ssh-identity-file PATH/-i: SSH identity (private key) file path (env:GERRIT_SSH_PRIVATE_KEY)--discovery-method [ssh|http|both]: Method for discovering projectsssh(default): Use SSH to query projects (requires SSH access)http: Use REST API (no SSH required; recommended for CI/CD)both: Union of both methods with SSH metadata preferred
--https/--ssh: Use HTTPS for cloning instead of SSH (default: SSH)--strict-host/--accept-unknown-host: SSH strict host key checking (default: strict)--skip-archived/--include-archived: Skip archived/read-only repositories (default: skip)
GitHub Configuration:
--org TEXT: Target GitHub organization (required or uses default from token)--github-token TEXT: GitHub PAT (or useGITHUB_TOKENenv var)--recreate: Delete and recreate existing GitHub repositories--overwrite: Overwrite local Git repositories at target path
Project Filtering:
--include-projects TEXT(aliases--include-project,--projects): Comma-separated list of project hierarchies to mirror--exclude-projects TEXT(alias--exclude-project): Projects to leave out; applied after include filters
Performance:
--threads INTEGER: Number of concurrent operations (default: auto)--output-path PATH: Local filesystem path for cloned projects (default:/tmp/gerrit-mirror)
Output:
--manifest-filename TEXT: Output manifest filename (default:mirror-manifest.json)--verbose/-v: Enable verbose/debug output--quiet/-q: Suppress all output except errors
The clone command takes the first GitHub token it finds, in this order:
--github-tokenSOURCE_CLONE_TOKENGERRIT_CLONE_TOKENGITHUB_TOKEN
GERRIT_CLONE_TOKEN keeps working, but prefer SOURCE_CLONE_TOKEN.
When GitHub rejects the token, the error names the source the token came
from. When a stale GERRIT_CLONE_TOKEN hides a valid GITHUB_TOKEN,
the error says so. The error never prints the token itself.
You can configure all CLI options through environment variables with
GERRIT_ prefix:
export GERRIT_HOST=gerrit.example.org
export GERRIT_PORT=29418
export GERRIT_SSH_USER=myuser
export GERRIT_SSH_PRIVATE_KEY=~/.ssh/gerrit_key
export OUTPUT_PATH=/workspace/repos
export GERRIT_SKIP_ARCHIVED=1
export GERRIT_THREADS=16
export GERRIT_CLONE_DEPTH=5
export GERRIT_BRANCH=main
export GERRIT_STRICT_HOST=1
export GERRIT_CLONE_TIMEOUT=300
export GERRIT_RETRY_ATTEMPTS=5
export GERRIT_DISCOVERY_METHOD=ssh
export GERRIT_CLEANUP=0
source-clone clone # Uses environment variablesSource-clone supports loading HTTP credentials from .netrc files, following
the standard format used by curl and other tools.
Search order:
.netrcin the current directory~/.netrcin your home directory~/_netrc(Windows fallback)
Example .netrc file:
machine gerrit.onap.org login myuser password mytoken
machine gerrit.opendaylight.org login myuser password anothertoken
CLI options:
| Option | Description |
|---|---|
--http-user TEXT |
HTTP username for Gerrit authentication |
--http-password TEXT |
HTTP password for Gerrit authentication |
--no-netrc |
Disable .netrc file lookup |
--netrc-file PATH |
Use a specific .netrc file |
--netrc-optional |
Do not fail if .netrc file is missing (default) |
--netrc-required |
Require a .netrc file and fail if missing |
By default, .netrc lookup is optional (--netrc-optional): if the tool
finds no .netrc file, it continues and falls back to environment variables.
Use --netrc-required to enforce that a .netrc file must be present.
When a .netrc file is present, credentials load automatically. Explicit
environment variables or CLI arguments take precedence over .netrc entries.
Credential Priority Order:
- CLI arguments (
--http-user/--http-password) - highest priority .netrcfile (if not disabled with--no-netrc)- Environment variables (
GERRIT_HTTP_USER,GERRIT_HTTP_PASSWORD) - Fallback environment variables (
GERRIT_USERNAME,GERRIT_PASSWORD)
The fallback environment variables (GERRIT_USERNAME/GERRIT_PASSWORD) provide
compatibility with other Gerrit-related actions and tools in the lfreleng-actions
ecosystem.
Example with explicit credentials:
# Use CLI credentials (highest priority)
source-clone clone --host gerrit.example.org --https \
--http-user myuser --http-password mytoken
# Use .netrc file
source-clone clone --host gerrit.example.org --https \
--netrc-file ~/.netrc.gerrit
# Require .netrc credentials (fail if not found)
source-clone clone --host gerrit.example.org --https --netrc-requiredCreate ~/.config/source-clone/config.yaml. When that directory holds no
config file, the tool reads ~/.config/gerrit-clone/, the directory earlier
releases used:
host: gerrit.example.org
port: 29418
ssh_user: myuser
ssh_identity_file: ~/.ssh/gerrit_key
path: /workspace/repos
skip_archived: true
threads: 8
clone_timeout: 600
retry_attempts: 3
retry_base_delay: 2.0Or JSON format ~/.config/source-clone/config.json:
{
"host": "gerrit.example.org",
"port": 29418,
"ssh_user": "myuser",
"ssh_identity_file": "~/.ssh/gerrit_key",
"path": "/workspace/repos",
"skip_archived": true,
"threads": 8
}Configuration precedence: CLI arguments > Environment variables > Config file > Defaults
The mirror command enables synchronizing Gerrit repositories to GitHub,
transforming hierarchical project structures into GitHub-compatible
repository names.
- Discovery: Discovers projects from the specified Gerrit server
- Filtering: Optionally filters to specific project hierarchies
- Name Transformation: Converts Gerrit paths to GitHub names
(
ccsdk/features→ccsdk-features) - Cloning: Creates local mirror clones from Gerrit
- GitHub Creation: Creates repositories in the target GitHub organization
- Pushing: Pushes complete repository history to GitHub
When you specify a project name like ccsdk, the mirror command
automatically includes all sub-projects in the hierarchy:
ccsdk(exact match)ccsdk/apps(child)ccsdk/features(child)ccsdk/features/test(grandchild)
This hierarchical filtering ensures the tool mirrors complete project families together.
GitHub does not support forward slashes in repository names, so the tool transforms Gerrit project paths:
| Gerrit Project Name | GitHub Repository Name |
|---|---|
ccsdk |
ccsdk |
ccsdk/apps |
ccsdk-apps |
ccsdk/features |
ccsdk-features |
ccsdk/features/test |
ccsdk-features-test |
GitHub mirroring requires a personal access token with appropriate permissions:
-
Create a token at https://github.com/settings/tokens
-
Required permissions:
For Classic Tokens:
repo(full control of private repositories)delete_repo(delete repositories) - Required for--recreateadmin:org(for organization repos) - Optional but recommended
For Fine-grained Tokens (Recommended):
- Contents: Read and Write
- Administration: Read and Write - Required for
--recreate - Metadata: Read access (automatically included)
-
Set the
GITHUB_TOKENenvironment variable:
export GITHUB_TOKEN=github_pat_your_token_hereDefault Behavior (without flags):
- Skips GitHub repositories that already exist
- Skips local repositories that already exist
- Creates new GitHub repositories as needed
- Clones from Gerrit if local path does not exist
With --recreate flag:
- Deletes and recreates existing GitHub repositories (fresh start)
- Still skips local clones if they exist
With --overwrite flag:
- Removes and re-clones local repositories, then pushes each one
(
git push --mirror) to its GitHub repository, existing ones included; the tree's recorded content filters still apply first - Leaves out of the run any repository a release up to v2.2.4
content-filtered, and any directory holding one: those releases recorded
no filters to apply again, so the run neither re-clones nor pushes it,
--recreateleaves its GitHub repository alone, and the manifest lists it as skipped - Without
--recreate, reuses existing GitHub repositories rather than deleting them
With both --recreate and --overwrite:
- Removes and re-clones all local repositories
- Deletes and recreates all GitHub repositories (complete refresh)
Basic mirror to an organization:
export GITHUB_TOKEN=ghp_your_token_here
source-clone mirror --server gerrit.onap.org --org modeseven-onapMirror specific projects with custom local output-path:
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--output-path /tmp/modeseven-onap \
--projects "ccsdk, oom, cps"Force-update all existing repositories:
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--recreate \
--overwriteMirror using custom SSH settings:
source-clone mirror \
--server gerrit.onap.org \
--org modeseven-onap \
--ssh-user myuser \
--ssh-identity-file ~/.ssh/gerrit_key \
--threads 8The mirror command generates a JSON manifest file
(mirror-manifest.json by default) with complete operation details:
{
"version": "1.0",
"generated_at": "2025-01-15T10:30:00Z",
"github_org": "modeseven-onap",
"gerrit_host": "gerrit.onap.org",
"total": 150,
"succeeded": 148,
"failed": 0,
"skipped": 2,
"duration_s": 1234.5,
"results": [
{
"gerrit_project": "ccsdk/apps",
"github_name": "ccsdk-apps",
"github_url": "https://github.com/modeseven-onap/ccsdk-apps",
"status": "success",
"local_path": "/tmp/modeseven-onap/ccsdk/apps",
"duration_s": 12.3,
"attempts": 1
}
]
}Source Clone includes intelligent support for nested repositories (projects with
hierarchical names like parent/child):
- Dependency Ordering: The tool automatically clones parent repositories before their children
- Conflict Detection: Identifies when parent repo content conflicts with nested directory structure
- Smart Batching: Uses dependency-aware batching to prevent race conditions
source-clone clone --host gerrit.example.org --no-move-conflictingSkips nested repositories when parent contains conflicting files/directories. Provides clear warnings about skipped repos.
source-clone clone --host gerrit.example.orgAutomatically moves conflicting content in parent repositories to
[NAME].parent to allow complete nested cloning. This ensures 100%
repository availability for reporting and analysis purposes.
Example:
- Parent repo
testcontains file namedtest - Child repo
test/testneeds directorytest/ - With move-conflicting enabled (default): File
test→test.parent, directory created for child repo - Result: The tool clones both repositories with complete history preservation
# Allow nested repositories (default: true)
--allow-nested-git / --no-allow-nested-git
# Protect parent repos by adding child paths to .git/info/exclude (default: true)
--nested-protection / --no-nested-protection
# Move conflicting content to allow complete cloning (default: true)
--move-conflicting / --no-move-conflictingname: Clone Gerrit Repositories
on: [push]
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Clone repositories
uses: lfreleng-actions/source-clone-action@v1
with:
host: gerrit.example.org
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
output-path: repositories
mirror: true # Bare mirrors with complete metadata (default: false)name: Clone and Process Repositories
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Clone repositories
id: clone
uses: lfreleng-actions/source-clone-action@v1
with:
host: gerrit.example.org
port: 29418
base-url: https://gerrit.example.org/gerrit
ssh-user: automation
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
output-path: workspace
skip-archived: true
threads: 12
mirror: false # Default: working copies (passes --no-mirror)
depth: 1
branch: main
use-https: false
keep-remote-protocol: false
clone-timeout: 900
retry-attempts: 5
verbose: true
- name: Show results
run: |
echo "Total: ${{ steps.clone.outputs.total-count }}"
echo "Succeeded: ${{ steps.clone.outputs.success-count }}"
echo "Failed: ${{ steps.clone.outputs.failure-count }}"
echo "Skipped: ${{ steps.clone.outputs.skipped-count }}"
echo "Refreshed: ${{ steps.clone.outputs.refreshed-count }}"
echo "Duration: ${{ steps.clone.outputs.duration }}s"
echo "Success rate: ${{ steps.clone.outputs.success-rate }}%"
echo "Manifest: ${{ steps.clone.outputs.manifest-path }}"
- name: Upload manifest
uses: actions/upload-artifact@v4
with:
name: clone-manifest
output-path: ${{ steps.clone.outputs.manifest-path }}name: Clone via HTTPS
on: [push]
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Clone repositories using HTTPS
uses: lfreleng-actions/source-clone-action@v1
with:
host: gerrit.example.org
base-url: https://gerrit.example.org/r
use-https: true
mirror: true # Complete mirror with all refs
output-path: repos
quiet: true
env:
# Use GitHub token or other auth for HTTPS
GIT_ASKPASS: echo
GIT_USERNAME: ${{ secrets.GERRIT_USERNAME }}
GIT_PASSWORD: ${{ secrets.GERRIT_TOKEN }}Note: When using
use-https: true, the action automatically setsdiscovery-method: httpto use the Gerrit REST API for project discovery. This is necessary because SSH discovery (the default) requires SSH access on port 29418, which is not available when using HTTPS. You can override this behavior by explicitly setting thediscovery-methodinput.
name: Complete Repository Mining
on: [workflow_dispatch]
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Clone all repositories (including nested with conflicts)
uses: lfreleng-actions/source-clone-action@v1
with:
host: gerrit.example.org
use-https: true
allow-nested-git: true
nested-protection: true
move-conflicting: true # Move conflicting files to ensure 100% clone success
output-path: complete-clone
threads: 8
verbose: true
- name: Verify complete data availability
run: |
echo "Cloned: ${{ steps.clone.outputs.success-count }}"
echo "Total repositories: ${{ steps.clone.outputs.total-count }}"
success_count=${{ steps.clone.outputs.success-count }}
total_count=${{ steps.clone.outputs.total-count }}
success_rate=$(( success_count * 100 / total_count ))
echo "Success rate: ${success_rate}%"
# Count moved conflicts
find complete-clone -name "*.parent" | wc -l | xargs echo "Conflicts resolved:"name: Clone with Config File
on: [workflow_dispatch]
jobs:
clone:
runs-on: ubuntu-latest
steps:
- name: Checkout config
uses: actions/checkout@v4
- name: Clone repositories
uses: lfreleng-actions/source-clone-action@v1
with:
config-file: .source-clone-config.yaml
verbose: true| Input | Required | Default | Description |
|---|---|---|---|
host |
Yes | Source hostname (Gerrit server or GitHub URL like github.com/ORG) |
|
port |
No | 29418 |
Gerrit SSH port |
base-url |
No | Base URL for Gerrit API (defaults to https://HOST) | |
ssh-user |
No | SSH username for clone operations | |
ssh-private-key |
No | SSH private key content for authentication | |
source-type |
No | Source type: gerrit or github (auto-detected from host) |
|
github-token |
No | GitHub personal access token; required for GitHub sources, public or private | |
github-org |
No | GitHub organization or user (auto-detected from host) | |
use-gh-cli |
No | false |
Use GitHub CLI (gh) for cloning instead of git |
mirror |
No | false |
false makes working copies; true makes bare mirrors; auto mirrors Gerrit sources and makes working copies of GitHub sources |
output-path |
No | . |
Clone destination; an empty value or a spelling of . such as ./ creates ./{SERVER}/ or ./github.com/{ORG}/; the tool uses any other value exactly as given |
skip-archived |
No | true |
Skip archived and inactive repositories |
include-projects |
No | Restrict to specific project(s); comma/space-separated, wildcard and hierarchical patterns | |
exclude-projects |
No | Exclude specific project(s); comma/space-separated, wildcard and hierarchical patterns | |
include-projects-file |
No | Path, relative to the workspace, to a file of include patterns; the file must exist inside the workspace and name a project | |
exclude-projects-file |
No | Path, relative to the workspace, to a file of exclude patterns; the file must exist inside the workspace and name a project | |
ssh-debug |
No | false |
Enable verbose SSH (-vvv) for troubleshooting |
allow-nested-git |
No | true |
Allow nested git working trees |
nested-protection |
No | true |
Auto-add nested child repo paths to parent .git/info/exclude |
move-conflicting |
No | false |
Move conflicting files/directories in parent repos to [NAME].parent |
exit-on-error |
No | false |
Exit when first error occurs |
no-refresh |
No | false |
Skip refreshing existing repositories |
force-refresh |
No | false |
Force refresh all existing repos (auto-stash, fix detached HEAD) |
force |
No | false |
Same as force-refresh: force refresh all existing repos (auto-stash, fix detached HEAD) |
fetch-only |
No | false |
Only fetch changes without merging (existing repos) |
skip-conflicts |
No | true |
Skip repos with uncommitted changes during refresh |
threads |
No | auto | Number of concurrent clone threads |
depth |
No | Create shallow clone with given depth | |
branch |
No | Clone specific branch instead of default | |
use-https |
No | false |
Use HTTPS for cloning instead of SSH |
https |
No | false |
Same as use-https: use HTTPS for cloning instead of SSH |
http-user |
No | HTTP username for Gerrit HTTPS authentication | |
http-password |
No | HTTP password for Gerrit HTTPS authentication | |
no-netrc |
No | false |
Disable .netrc credential lookup for HTTP auth |
netrc-file |
No | Explicit path to .netrc file for HTTP credentials | |
netrc-optional |
No | true |
Whether missing .netrc is acceptable (false = fail if not found) |
keep-remote-protocol |
No | false |
Keep original clone protocol for remote |
strict-host |
No | true |
SSH strict host key checking |
clone-timeout |
No | 600 |
Timeout per clone operation in seconds |
retry-attempts |
No | 3 |
Max retry attempts per repository |
retry-base-delay |
No | 2.0 |
Base delay for retry backoff in seconds |
retry-factor |
No | 2.0 |
Exponential backoff factor for retries |
retry-max-delay |
No | 30.0 |
Max retry delay in seconds |
manifest-filename |
No | clone-manifest.json |
Output manifest filename |
config-file |
No | Configuration file path (YAML or JSON) | |
verbose |
No | false |
Enable verbose/debug output |
quiet |
No | false |
Suppress all output except errors |
log-file |
No | Custom log file path | |
disable-log-file |
No | false |
Disable creation of log file |
log-level |
No | DEBUG |
File logging level |
| Output | Description |
|---|---|
manifest-path |
Path to the generated clone manifest file |
total-count |
Total number of repositories processed |
success-count |
Number of successfully cloned repositories |
failure-count |
Number of failed clone attempts |
skipped-count |
Number of skipped repositories |
already-exists-count |
Repos that already existed (not refreshed) |
refreshed-count |
Existing repos that pulled new changes |
verified-count |
Repos verified as up-to-date (no changes) |
duration |
Total duration of the operation in seconds |
success-rate |
Success rate as a percentage |
The tool provides comprehensive SSH authentication support with automatic configuration detection:
The following SSH authentication options are available across all interfaces:
| Option | CLI | Environment | Action | Description |
|---|---|---|---|---|
| SSH User | -u |
GERRIT_SSH_USER |
ssh-user |
SSH username |
| SSH Key | -i (file path) |
GERRIT_SSH_PRIVATE_KEY |
ssh-private-key (content) |
Identity file |
| Host Check | --strict-host |
GERRIT_STRICT_HOST |
strict-host |
Key check |
Note: The CLI flag
--ssh-identity-file/-iand theGERRIT_SSH_PRIVATE_KEYenvironment variable expect a file path to a private key on disk. The GitHub Action inputssh-private-keyexpects the raw key content (loaded into an SSH agent). Never place key content inGERRIT_SSH_PRIVATE_KEY: the CLI rejects it, without echoing the value. In workflows, hold the secret in a differently named variable and pipe it tossh-add -. The legacy CLI alias--ssh-private-keyis still accepted for backward compatibility.
Three authentication methods provide automatic fallback:
- SSH Agent (Recommended): Uses keys loaded into SSH agent with automatic detection
- Identity File: Explicitly specified private key files with permission validation
- SSH Config: Host-specific configuration from ~/.ssh/config with full option support
-
Generate SSH key pair:
ssh-keygen -t ed25519 -C "your.email@example.com" -
Add public key to Gerrit profile
-
Add private key to SSH agent:
ssh-add ~/.ssh/id_ed25519 -
Clone with agent authentication:
source-clone clone --host gerrit.example.org --ssh-user myuser
-
Place private key file securely (e.g.,
/path/to/private_key) -
Set proper permissions:
chmod 600 /path/to/private_key
-
Clone with identity file:
source-clone clone --host gerrit.example.org \ --ssh-user myuser \ --ssh-identity-file /path/to/private_key
-
Or use environment variables:
export GERRIT_SSH_USER=myuser export GERRIT_SSH_PRIVATE_KEY=/path/to/private_key source-clone clone --host gerrit.example.org
Create ~/.ssh/config entries for convenience:
Host gerrit.example.org
User myusername
IdentityFile ~/.ssh/gerrit_key
StrictHostKeyChecking yes
Pre-populate known hosts to avoid prompts (recommended for CI/CD):
ssh-keyscan -H -p 29418 gerrit.example.org >> ~/.ssh/known_hostsTest SSH connectivity before cloning:
ssh -p 29418 myuser@gerrit.example.org gerrit versionEach run generates a detailed JSON manifest (clone-manifest.json):
{
"version": "1.0",
"generated_at": "2025-01-15T10:30:45Z",
"host": "gerrit.example.org",
"port": 29418,
"total": 42,
"succeeded": 154,
"failed": 2,
"skipped": 0,
"success_rate": 98.7,
"duration_s": 89.3,
"config": {
"skip_archived": true,
"threads": 8,
"depth": null,
"branch": null,
"strict_host_checking": true,
"path": "/workspace/repos",
"include_projects": ["core/*"],
"exclude_projects": []
},
"content_filters": {
"intent_file": "/workspace/repos/.gerrit-clone/filter-policy.json",
"scopes": [{ "projects": "*", "remove": [".github/dependabot.yml"] }]
},
"results": [
{
"project": "core/api",
"path": "core/api",
"status": "success",
"attempts": 1,
"duration_s": 3.42,
"error": null,
"started_at": "2025-01-15T10:30:15Z",
"completed_at": "2025-01-15T10:30:18Z"
},
{
"project": "tools/legacy",
"path": "tools/legacy",
"status": "failed",
"attempts": 3,
"duration_s": 15.8,
"error": "timeout after 600s",
"started_at": "2025-01-15T10:30:20Z",
"completed_at": "2025-01-15T10:30:36Z"
}
]
}# Accept new host keys (use with caution)
source-clone clone --host gerrit.example.org --accept-unknown-host
# Recommended: Pre-populate known_hosts
ssh-keyscan -H -p 29418 gerrit.example.org >> ~/.ssh/known_hosts- Verify SSH public key exists in Gerrit profile
- Check SSH agent has key loaded:
ssh-add -l - Test SSH connection:
ssh -p 29418 username@gerrit.example.org gerrit version - Verify SSH key permissions:
chmod 600 ~/.ssh/id_rsa
- Verify Gerrit server hostname and port (often 29418 for SSH)
- Check network connectivity and firewall rules
- Increase timeout:
--clone-timeout 900 - Reduce concurrency:
--threads 4
- Existing non-git directories block clones
- Use clean target directory:
--output-path ./clean-workspace - Check disk space and write permissions
- Remove conflicting directories:
rm -rf conflicting-path
- Manually specify base URL:
--base-url https://host/gerrit - Verify Gerrit server is accessible via HTTPS
- Check for corporate proxy or firewall restrictions
The tool uses standardized exit codes for different failure types, making it easier to handle errors in automation and CI/CD pipelines:
| Exit Code | Description | Common Causes | Resolution |
|---|---|---|---|
| 0 | Success | All repositories cloned | N/A |
| 1 | General Error | Unexpected operational failure | Check logs |
| 2 | Configuration Error | Invalid or missing settings | Verify inputs |
| 3 | Discovery Error | Failed to discover projects | Check network and API |
| 4 | Gerrit Connection Error | SSH auth or connection failed | Verify SSH keys |
| 5 | Network Error | Network connectivity issues | Check connection |
| 6 | Repository Error | Git operation failed | Verify permissions |
| 7 | Clone Error | Clone operations failed | Check access |
| 8 | Validation Error | Input validation failed | Check parameters |
| 9 | Filesystem Error | Filesystem access issues | Check disk space |
| 130 | Interrupted | Cancelled by user (Ctrl+C) | N/A |
When using --discovery-method both, the tool now:
- Attempts both HTTP and SSH discovery methods simultaneously
- Creates a union of all projects found by either method when both succeed
- Prefers SSH metadata for duplicate projects (same name) as SSH typically provides more complete information
- Continues with working method if one fails, logging a warning
- Exits with code 3 if both methods fail (fatal discovery error)
- Includes warnings in output about any discovery method failures and discrepancies
This provides better reliability and completeness by ensuring all projects get cloned, while maintaining visibility into discovery issues between the two methods.
- Python 3.11+ (tested on 3.11, 3.12, 3.13, 3.14)
- uv package manager (for development)
- Git 2.31+ (for clone operations)
- libcurl 7.58+ (for HTTPS token authentication)
- SSH client (for authentication)
Note: Git 2.31 (March 2021) introduced the
GIT_CONFIG_COUNT/GIT_CONFIG_KEY_*/GIT_CONFIG_VALUE_*environment variables. Both the clone and mirror-push paths use them to pass a GitHub token togit, so the token stays out of the command line and out of the host's process listing. Older Git releases ignore those variables, and HTTPS token authentication will fail.The token travels as an
Authorizationheader scoped to the source host. Git hands that to libcurl as a custom header, and libcurl before 7.58 (January 2018, CVE-2018-1000007) forwards a customAuthorizationto a different host across a redirect. Every current distribution ships a later release; the floor matters only for a long-lived self-hosted runner.
git clone https://github.com/lfreleng-actions/source-clone-action.git
cd source-clone-action
uv sync --dev# Run all tests
uv run pytest
# Run with coverage report
uv run pytest --cov=source_clone --cov-report=html --cov-report=term-missing
# Run integration tests (requires network)
uv run pytest tests/integration/ -v
# Run specific test categories
uv run pytest -m "not integration" -v # Unit tests
uv run pytest tests/test_models.py::TestConfig -v # Specific test classTwo Atheris harnesses in
tests/fuzz/ check contracts that protect credentials and the
clone directory:
fuzz_url_safety.py: clone URL checks never accept a password or token, redaction removes userinfo and secrets, and parsing a remote returns a location or nothing.fuzz_project_paths.py: a project name always maps to a path under the base directory.
Atheris is not a project dependency. Run a harness with it added for one command:
# Fuzz for 60 seconds
uv run --with atheris python tests/fuzz/fuzz_url_safety.py -max_total_time=60
# Replay one input file, such as a crash file
uv run --with atheris python tests/fuzz/fuzz_project_paths.py crash-fileEach harness keeps seed inputs, including past findings. The unit
test tests/unit/test_fuzz_harnesses.py replays every seed without
Atheris, so the normal test run guards these contracts.
# Run pre-commit hooks
uv run pre-commit run --all-files
# Individual tools
uv run ruff check .
uv run ruff format .
uv run mypy src/This project uses the Apache License 2.0. See LICENSE for details.
- Fork the repository
- Create a feature branch
- Make changes with tests
- Run linting and tests
- Submit a pull request
- GitHub Issues: Report bugs and request features at lfreleng-actions/source-clone-action
- Documentation: This README, IMPLEMENTATION.md, and inline help
(
source-clone --help) - Examples: Advanced usage patterns in repository examples/
- Integration Tests: Real-world server validation in tests/integration/