GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add opt-in singleBranch option to speed up git scm checkout by kuisathaverat · Pull Request #9590 · updatecli/updatecli

Conversation

@kuisathaverat

@kuisathaverat kuisathaverat commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Updatecli pipelines targeting repositories with a very large number of branches, tags, and other refs (hundreds of branches/tags, 350k+ commits) can spend a very long time (measured up to ~19 minutes) just checking out the git scm, even when depth is set to a low value.

Two issues were found in the shared native git implementation used by every git-based scm (github, gitlab, gitea, bitbucket, stash, azuredevops, git) — pkg/plugins/utils/gitgeneric (GoGit, built on go-git):

  1. The initial clone fetches every branch on the remote. git.CloneOptions is built without SingleBranch/ReferenceName, so go-git falls back to its default refspec +refs/heads/*:refs/remotes/<remote>/* (all branches) — depth only limits the commit history per ref, not the number of refs fetched.
  2. A forced, unconditional "mirror" fetch runs after every clone, using RefSpecs: []config.RefSpec{"refs/*:refs/*"}. This matches every ref namespace on the remote — not just branches and tags, but also refs/pull/*, refs/notes/*, and any other custom ref — on every single Updatecli execution, whether the local clone was fresh or reused.

For a repository with hundreds of branches/tags and a long history, this second point in particular is extremely expensive and explains slow checkouts even with depth configured.

Solution

This PR adds a new opt-in singleBranch option to every git-based scm's spec (github, gitlab, gitea, bitbucket, stash, azuredevops, git), following the same pattern as the existing submodules/depth options.

When singleBranch: true is set:

  • The initial clone only fetches the configured branch (SingleBranch: true + ReferenceName on git.CloneOptions), instead of every branch on the remote.
  • The post-clone refs/*:refs/* reconciliation fetch is skipped entirely.

When the option is left unset (default), behavior is 100% unchanged — this is purely opt-in.

Trade-off

Skipping the full ref reconciliation fetch means Updatecli may, in some edge cases, fail to detect an already-published working branch and create a duplicate pull request. This is documented on the new option and is an acceptable trade-off compared to multi-minute checkouts on very large repositories.

Example

scms:
  default:
    kind: github
    spec:
      owner: updatecli
      repository: updatecli
      branch: main
      token: '{{ requiredEnv "GITHUB_TOKEN" }}'
      depth: 1
      singleBranch: true

Impact

Measured on a repository with hundreds of branches/tags and ~350k commits, enabling singleBranch reduced the scm checkout time from ~19 minutes to ~43 seconds.

Validation

  • go build ./...
  • go vet ./pkg/plugins/scms/... ./pkg/plugins/utils/gitgeneric/...
  • go test ./pkg/plugins/scms/... ./pkg/plugins/utils/gitgeneric/... — all pass (one pre-existing, unrelated failure in TestGoGit_RemoteURLs confirmed present on main as well, due to the local worktree environment)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

v1v reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@kuisathaverat
feat: add opt-in singleBranch option to speed up git scm checkout
d7ad2b2
Repositories with a very large number of branches, tags, and other refs
(e.g. hundreds of branches/tags and hundreds of thousands of commits) can
make Updatecli's git scm checkout very slow, even when a shallow `depth`
is configured. There are two contributing factors in
`pkg/plugins/utils/gitgeneric` (GoGit, shared by the github, gitlab,
gitea, bitbucket, stash, azuredevops and git scms):

- The initial `git.PlainClone` fetches every branch on the remote by
  default (go-git's default clone refspec is
  `+refs/heads/*:refs/remotes/<remote>/*`), regardless of `depth`.
- Right after cloning, an unconditional fetch is issued with
  `RefSpecs: []config.RefSpec{"refs/*:refs/*"}`, which mirrors every ref
  on the remote (branches, tags, pull request refs, notes, etc.) on every
  single Updatecli execution.

This change adds a new opt-in `singleBranch` spec field. When enabled:
- the clone only fetches the configured branch
  (`SingleBranch`+`ReferenceName` on `git.CloneOptions`), and
- the post-clone `refs/*:refs/*` reconciliation fetch is skipped
  entirely.

Default behavior (flag unset) is unchanged. As a documented trade-off,
enabling `singleBranch` skips the full ref reconciliation, which in some
edge cases can make Updatecli miss an already published working branch
and create a duplicate pull request.

Co-authored-by: Copilot App <[email protected]>
@kuisathaverat kuisathaverat mentioned this pull request Jul 14, 2026
docs(scm): document singleBranch/depth performance option updatecli/website#3514
Merged
@olblak
Merge branch 'main' into kuisathaverat-optimize-scm-checkout-depth
0489d9a
olblak
olblak previously approved these changes Jul 15, 2026
View reviewed changes

@olblak olblak left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the great pull request, covering all scm provider plus the documentation.
I assume you tested it so I am happy to merge as is

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@olblak
Merge branch 'main' into kuisathaverat-optimize-scm-checkout-depth
883c99a
@kuisathaverat

kuisathaverat commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

I made a test with the repository that hit the issue, we moved from 19 minutes to process the pipeline to 43 seconds

olblak reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mergify

mergify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kuisathaverat and others added 2 commits July 15, 2026 12:28
@kuisathaverat
fix: correct typo Successer -> Successor in shell resource
6183807
The typos CI check fails on main (e.g. PR updatecli#9565) due to a pre-existing
spelling typo unrelated to the singleBranch scm change. Fixing it here
so this PR's CI can pass cleanly.

Co-authored-by: Copilot App <[email protected]>
@kuisathaverat
Merge remote-tracking branch 'fork/kuisathaverat-optimize-scm-checkou…
f0b719a
…t-depth'
@kuisathaverat
kuisathaverat dismissed olblak’s stale review via f0b719a July 15, 2026 10:29
kuisathaverat
kuisathaverat commented Jul 15, 2026
View reviewed changes
Comment thread pkg/plugins/resources/shell/changeIf.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

kuisathaverat
kuisathaverat commented Jul 15, 2026
View reviewed changes
Comment thread pkg/plugins/resources/shell/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kuisathaverat
Revert "fix: correct typo Successer -> Successor in shell resource"
80fbca5
This reverts commit 6183807.
@kuisathaverat

kuisathaverat commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

There are some issues with the Check Spell, but they are in files that I did not touch, so I will not fix them. As a reference, this is the fix 6183807. I will revert now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kuisathaverat
kuisathaverat requested a review from olblak July 15, 2026 10:35
@olblak

olblak commented Jul 15, 2026

Copy link
Copy Markdown
Member

It now complains because of this pullrequest that I merged this morning https://github.com/updatecli/updatecli/pull/9565/checks

I can fix it in a different pr

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak olblak mentioned this pull request Jul 15, 2026
fix(shell): function typo #9608
Merged
1 task
@olblak
Merge branch 'main' into kuisathaverat-optimize-scm-checkout-depth
6fc5701
olblak
olblak approved these changes Jul 15, 2026
View reviewed changes
@olblak
olblak merged commit 6b3fff2 into updatecli:main Jul 16, 2026
8 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@olblak olblak added enhancement New feature or request scm-github SCM of type GiHhub scm-git SCM of kind "Git" scm-gittea scm-gitlab scm-stash scm-bitbucket All things related to the bitbucket integration scm-githubsearch scm-gitlabsearch scm-azuredevops labels Jul 22, 2026
olblak added a commit to updatecli/website that referenced this pull request Aug 6, 2026
@kuisathaverat @olblak
docs(scm): document singleBranch/depth performance option (#3514)
612ebf8
Adds a new 'Performance on large repositories' subsection to each scm
plugin doc (github, gitlab, gitea, bitbucket, stash, azuredevops, git)
explaining the new singleBranch option (paired with depth) that lets
Updatecli skip fetching every branch, tag, and ref on the remote,
along with a runnable example for each plugin.

Related to updatecli/updatecli#9590.

Co-authored-by: kuisathaverat <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Olblak <[email protected]>
Co-authored-by: Olivier Vernin <[email protected]>
@v1v v1v mentioned this pull request Oct 1, 2026
Add automated GitHub Actions workflow for bumping npcap in elastic/beats elastic/beats#53508
Merged
3 tasks
@mallendem mallendem mentioned this pull request Oct 8, 2026
fix(git): fetch working branch with singlebranch and commitusingapi #10822
Merged
1 of 2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@olblak olblak olblak approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request scm-azuredevops scm-bitbucket All things related to the bitbucket integration scm-git SCM of kind "Git" scm-github SCM of type GiHhub scm-githubsearch scm-gitlab scm-gitlabsearch scm-gittea scm-stash

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@kuisathaverat @olblak
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.