Commit fc408e8b authored by Stan Hu's avatar Stan Hu

Ensure .git/config is updated for forks

Normally when a project is created, `Projects::CreateService` attempts
to initialize a Git directory and update the `.git/config` to include
the human-readable project full path. However, for forks and project
imports, the repository is imported in a separate background task. As a
result, attempts to write to the `.git/config` directory will fail
unless the job has completed first.

To ensure we always update `.git/config` after the import is complete,
we call this update in `Project#after_import`.

Relates to https://gitlab.com/gitlab-org/gitaly/-/issues/2902
parent b163b72f
......@@ -1802,6 +1802,7 @@ class Project < ApplicationRecord
after_create_default_branch
join_pool_repository
refresh_markdown_cache!
write_repository_config
end
def update_project_counter_caches
......
---
title: Ensure .git/config is updated for forks
merge_request: 35305
author:
type: fixed
......@@ -4663,6 +4663,7 @@ RSpec.describe Project do
expect(project).to receive(:refresh_markdown_cache!)
expect(InternalId).to receive(:flush_records!).with(project: project)
expect(DetectRepositoryLanguagesWorker).to receive(:perform_async).with(project.id)
expect(project).to receive(:write_repository_config)
project.after_import
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment