Closed
fix: add per-repo+branch mutex to prevent concurrent git lock errors#4014
Conversation
Adds GET /repositories/{id}/playbooks, returning .yml/.yaml paths found
in the repo (optionally at a given branch), so template creation can
offer a picker instead of requiring a hand-typed playbook path. Local
repos are read directly; git/ssh/https repos get a scratch checkout
per branch (git clone/pull is single-branch, so one dir per branch
avoids failed checkouts on branch switch).
Replaces the free-text playbook field with an autocomplete populated
from the new /repositories/{id}/playbooks endpoint, mirroring the
existing git-branch picker's pattern (falls back to free text if the
list can't be loaded). Reloads on repository or branch change.
Dedupe nopLogger into task_logger.NopLogger, shared by api/projects/repository.go and db_lib test. Clean up orphaned/corrupt clone directory on git.Clone() failure so retries don't get stuck on ValidateRepo() passing against a broken checkout. Parallelize loadBranches/loadPlaybooks in TemplateForm.vue since they're independent.
For local repositories, GET .../branches returns 400. Without a try/catch, that rejection propagated out of loadBranches() and (now that loadBranches/loadPlaybooks run via Promise.all) prevented the playbook dropdown from populating. Mirrors the existing try/catch in loadPlaybooks().
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Concurrent requests for the same repo+branch can race on .git/index.lock in the shared scratch checkout. Add a sync.Map-based per-directory mutex that serializes ValidateRepo/Clone/Pull operations for each unique repo+branch combination.
Copilot
AI
changed the title
[WIP] Fix code based on the review comment
fix: add per-repo+branch mutex to prevent concurrent git lock errors
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GetRepositoryPlaybooksreuses a shared scratch checkout per repo+branch and runsgit pullon every request. Concurrent requests for the same repo+branch race on.git/index.lock, causing corruption or failures.sync.Map-based per-directory mutex that serializesValidateRepo/Clone/Pullfor each unique repo+branch scratch checkout