mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-10 05:32:52 -05:00
Template Repository #3540
Closed
opened 2025-11-02 05:16:23 -06:00 by GiteaMirror
·
27 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0
v1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
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#3540
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lunny on GitHub (Jul 6, 2019).
A repository could be a template repository.
This will replace #2062 #7359 .
@silverwind commented on GitHub (Jul 7, 2019):
Feature idea: Variable replacement in a template repo's file. For example, variables such as:
These variables could be one-time replaced at creation time. As far as I know, GitHub's template feature does not support such a feature yet.
Copying non-git content should be optional. It brings problem of what to do with absolute URLs that point to the template repo itself. Not sure we should even attempt to rewrite those.
@davidsvantesson commented on GitHub (Aug 14, 2019):
Current readme template already support {Name} and {Description}. I think it should be the same variable replacement for template repos but in all md files (and possibly other file types as well, maybe configurable)
I agree it would be error prone to try to fix URLs, but instead more generic variables could be added to settings. For example the External Issue Tracker URL Format already support placeholders {user}, {repo} and {index}.
@stale[bot] commented on GitHub (Oct 13, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@davidsvantesson commented on GitHub (Oct 13, 2019):
Too good idea to be closed. 💚
@jolheiser commented on GitHub (Oct 29, 2019):
That could be quite a large list (especially for admins). Why not do it how GitHub does, where it's a
Generate using this templatebutton on the template's page?I agree with @silverwind that only git content should be copied (at least at first?)
When creating a new repo using a template, the screen to create the repo could be almost identical to making a new bare repo. You can name it, make it private or not, and give it a description.
Since most of the
initthings would be taken care of by the template, the only other field I can think of is adding a label set at creation time, but in my opinion this should be a field when creating, not carried over from template.Issues/PRs don't make sense to copy (in my opinion) because those would be issues/PRs towards the template, not necessarily the project you are using the template for.
@guillep2k commented on GitHub (Oct 29, 2019):
Wikis and avatars are things that could come from templates as well. I use repo avatars to convey the type of repo it is (e.g. library, utility, firmware related, electronic, mechanical, etc.).
IMHO this function could be emulated by a migration from the same instance. The admin/org owner can have as many template repos as they want and clone them by migration gitea-to-gitea. It would be cool if Gitea would let you choose what items not to migrate (e.g. not issues or not teams).
@davidsvantesson commented on GitHub (Oct 30, 2019):
It can be made searchable, but I agree it is a good idea to at least allow selecting directly on the template repo.
It would be good to allow selecting what content you want to copy (or not copy) from the template repo.
@jolheiser commented on GitHub (Nov 1, 2019):
@guillep2k commented on GitHub (Nov 1, 2019):
@jolheiser I'd add to that list:
@davidsvantesson commented on GitHub (Nov 1, 2019):
Some more to make the list complete:
@lunny commented on GitHub (Nov 2, 2019):
@davidsvantesson commented on GitHub (Nov 4, 2019):
Regarding the variable replacement, I think there are two possibilities. Either make a new commit with the variables replaced, OR replace every time the markdown is rendered in the UI. Both options have some pros and cons. I prefer the later, but it would not work as well with other git services.
@jolheiser commented on GitHub (Nov 4, 2019):
The replacement would happen at generation time in the same initial commit.
@jolheiser commented on GitHub (Nov 5, 2019):
@guillep2k @davidsvantesson
I don't think branches or releases can be carried over, as both of those rely on commits that won't exist once the repository is generated.
A generated repository acts like an initial commit based on the files in the template at the time of generation. It doesn't keep the history of the template repository, as it may have no meaning to the generated project.
All of the above can be changed (and made optional) by someone else, however it is not my current intention for this implementation.
@davidsvantesson commented on GitHub (Nov 5, 2019):
That was not my impression. There can be two possibilities for how a repository is created from a template:
I think the first shall at least be an option! History of the template might be interesting for the created repository or not. However the main point of cloning rather than copying is that if someone later change the template, it will be much easier to merge in those changes later as git keeps track of was what changes since you created from the template.
@jolheiser commented on GitHub (Nov 5, 2019):
That sounds like a fork or migration imo
I think we are having different ideas of what a template is and what to use it for.
In my opinion, it should be a starting place for a new project and nothing more.
Merging in upstream template changes makes no sense to me once I have started work on the generated project.
If you mean keep a personal copy of the template to merge upstream changes from, that would be forking the template and adding your own commits to it.
EDIT: I think we are starting to split hairs, but this is a good conversation to clarify how future PRs may (or may not) be implemented.
@davidsvantesson commented on GitHub (Nov 5, 2019):
In the PR you said something about you shared code from the forking process, so I somehow thought it would be a cloning process :) (I havn't checked the details of the implementation yet).
Forking in Gitea (and Github) usually means you intend to contribute back to the original repository. In GitHub I don't think you even can choose to fork to the same user as owns the repository? So I don't think that has the same usage. At least I don't want to keep it as a tracked fork because normally there will be no pull request back to the template. Migration is in my view more used between different sites, even if it is possible within one site. So maybe that is more close to what I expect.
My idea of a template is that you can have set up some basic software structure (maybe even a complete rudimentary software) that you use to make other software from. The history can be interesting if you want to know why something was made in a certain way. If someone makes an update to the template, you might want to try merge it back (so that is the opposite way than a normal pull request).
@jolheiser commented on GitHub (Nov 5, 2019):
Oh! That's my bad, I maybe worded it poorly.
It shared code in the sense that it is a repo based on another repo, but there are key differences because if the implementation.
Sorry for the confusion.
I agree the history is nice to see, however that's partially what the "generated from x" sub-title is for, since the commit history makes sense for the template (but not necessarily the generated project)
This process very closely resembles how GitHub uses templates. (Maybe not code-wise, but in terms of the end result)
@guillep2k commented on GitHub (Nov 5, 2019):
Regarding the copy of all the branches and/or the history, my view is as follows:
HEADfrom the default branch should be copied as this is only a template, after all, and one might want to start a repo with a clean history.HEAD, likemaster.I think that copying branches is useful, and I'll give an example to illustrate my idea. Imagine a template (in Gitea from the future! 😄) with:
masterbranch (default), protected, requires approvals from team X to merge.devbranch, protected, no approvals required but can only be merged through PRs.QAbranch, protected, requires approvals from team Z to merge.What I mean is that an org can have all the permissions already set up for the template according to their usual workflow, and when they create the new repo these permissions are carried onto it. Of course this only applies if permissions are copied too.
@jolheiser commented on GitHub (Nov 5, 2019):
@guillep2k I see what you mean now, and I agree. 👍
@lunny commented on GitHub (Nov 11, 2019):
init project. And the author and committer is the repository creator.@jolheiser commented on GitHub (Nov 11, 2019):
Regarding auto-expansion of variables in content, what should all be mapped (and what content should be affected?)
I'm thinking git content and git hooks currently. (Probably the wiki in the future as well, but that's almost an entirely separate beast)
For mapping, I was thinking of giving it the entire
models.Repositorybut that might not be a wise decision. e.g don'tSELECT *when you can choose what fields explicitly. 😉Per @silverwind (modified to match what
os.Expandexpects)${REPO_NAME}
${REPO_OWNER}
${REPO_HTTPS_URL}
${REPO_SSH_URL}
Anything specific to a repository I would probably also make the same variable available as old and new.
e.g.
${TEMPLATE_NAME} and ${REPO_NAME}
@lunny commented on GitHub (Nov 12, 2019):
@jolheiser Could you add https://github.com/go-gitea/gitea/issues/7365#issuecomment-552491746 to you to do list?
@jolheiser commented on GitHub (Nov 12, 2019):
I can, but if I understand it correctly it may not be needed. Currently there are no commits to squash because the newly generated repository abandons the history of the template.
@jolheiser commented on GitHub (Nov 19, 2019):
@lunny Could you add https://github.com/go-gitea/gitea/issues/7365#issuecomment-548647643 to your description so it's easier to jump to what is and isn't implemented yet?
Alternatively, I could open a new issue to continue this one so that I can update the head comment.
@lunny commented on GitHub (Nov 22, 2019):
@jolheiser We need a feature on gitea to transfer an issue's owner. :) Please open a new issue and I will close this one. Let's discuss there.
@lunny commented on GitHub (Nov 23, 2019):
Continue on #9126