Custom groups and instance level project templates retain commit history and pipelines
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Custom group and instance level project templates rely on cloning a source repository to be used as a base for a project.
However, these templates clone the source project and retain the commit history, including pipelines.
Built-in templates do not retain their commit history and pipelines.
Steps to reproduce
- Create a project from a template at the instance or group level.
- Observe the project history
Example Project
Group template
https://gitlab.com/Lyle-Ephemeral-Test-Group/project-templates/created-using-project-template-test/ was created from template: https://gitlab.com/Lyle-Ephemeral-Test-Group/project-templates/project-template-test/
Of note:
- Commit history includes all commits from source template.
- Pipelines history includes all pipelines from source template.
The same behaviour is true for custom instance-level project templates.
Built in templates
- Commit history does not include history, but links to source template. See relevant commit points to https://gitlab.com/gitlab-org/project-templates/rails
What is the current bug behavior?
Custom group and instance level templates import all history and CI pipelines from the source project.
What is the expected correct behavior?
Custom group and instance level project templates act consistently with built-in templates and squash history into a single commit. CI pipelines are not imported.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
Workaround(s)
Squash commits on either the source project after making changes, or projects created using the template. See an example project for this looks. To do this you can run the one-liner git reset $(git commit-tree HEAD^{tree} -m "A new start")
suggested in https://stackoverflow.com/questions/1657017/how-to-squash-all-git-commits-into-one and git push -f
to force push the result. This will not clean up pipelines from the source project if they are present.