Skip to content

Commit eb02be9

Browse files
committed
use GitRemoteName
1 parent 967ab29 commit eb02be9

File tree

9 files changed

+25
-19
lines changed

9 files changed

+25
-19
lines changed

modules/setting/config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,16 @@ func DefaultOpenWithEditorApps() OpenWithEditorAppsType {
4949

5050
type RepositoryStruct struct {
5151
OpenWithEditorApps *config.Value[OpenWithEditorAppsType]
52-
SnippetRemoteName *config.Value[string]
52+
}
53+
54+
type TemplateStruct struct {
55+
GitRemoteName *config.Value[string]
5356
}
5457

5558
type ConfigStruct struct {
5659
Picture *PictureStruct
5760
Repository *RepositoryStruct
61+
Template *TemplateStruct
5862
}
5963

6064
var (
@@ -71,7 +75,9 @@ func initDefaultConfig() {
7175
},
7276
Repository: &RepositoryStruct{
7377
OpenWithEditorApps: config.ValueJSON[OpenWithEditorAppsType]("repository.open-with.editor-apps"),
74-
SnippetRemoteName: config.ValueJSON[string]("repository.snippet-remote-name").WithDefault("origin"),
78+
},
79+
Template: &TemplateStruct{
80+
GitRemoteName: config.ValueJSON[string]("template.git-remote-name").WithDefault("origin"),
7581
},
7682
}
7783
}

options/locale/locale_en-US.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,8 +3419,8 @@ config.disable_gravatar = Disable Gravatar
34193419
config.enable_federated_avatar = Enable Federated Avatars
34203420
config.open_with_editor_app_help = The "Open with" editors for the clone menu. If left empty, the default will be used. Expand to see the default.
34213421
3422-
config.repository_snippets = Repository Snippets
3423-
config.repository_snippets.remote_name = Remote name (default: origin)
3422+
config.empty_repo_page = Empty Repo Page
3423+
config.empty_repo_page.git_remote_name = Git Remote Name (default: origin)
34243424
34253425
config.git_config = Git Configuration
34263426
config.git_disable_diff_highlight = Disable Diff Syntax Highlight

routers/web/admin/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func ChangeConfig(ctx *context.Context) {
248248
cfg.Picture.DisableGravatar.DynKey(): marshalBool,
249249
cfg.Picture.EnableFederatedAvatar.DynKey(): marshalBool,
250250
cfg.Repository.OpenWithEditorApps.DynKey(): marshalOpenWithApps,
251-
cfg.Repository.SnippetRemoteName.DynKey(): marshalStringWithDefault(cfg.Repository.SnippetRemoteName.Def()),
251+
cfg.Template.GitRemoteName.DynKey(): marshalStringWithDefault(cfg.Template.GitRemoteName.Def()),
252252
}
253253
marshaller, hasMarshaller := marshallers[key]
254254
if !hasMarshaller {

routers/web/repo/issue_view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func ViewPullMergeBox(ctx *context.Context) {
446446

447447
// TODO: it should use a dedicated struct to render the pull merge box, to make sure all data is prepared correctly
448448
ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.Doer.ID)
449-
ctx.Data["SnippetRemoteName"] = setting.Config().Repository.SnippetRemoteName.Value(ctx)
449+
ctx.Data["GitRemoteName"] = setting.Config().Template.GitRemoteName.Value(ctx)
450450
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
451451
ctx.HTML(http.StatusOK, tplPullMergeBox)
452452
}

services/context/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ func RepoAssignment(ctx *Context) {
542542
ctx.Data["CanWriteIssues"] = ctx.Repo.CanWrite(unit_model.TypeIssues)
543543
ctx.Data["CanWritePulls"] = ctx.Repo.CanWrite(unit_model.TypePullRequests)
544544
ctx.Data["CanWriteActions"] = ctx.Repo.CanWrite(unit_model.TypeActions)
545-
ctx.Data["SnippetRemoteName"] = setting.Config().Repository.SnippetRemoteName.Value(ctx)
545+
ctx.Data["GitRemoteName"] = setting.Config().Template.GitRemoteName.Value(ctx)
546546

547547
canSignedUserFork, err := repo_module.CanUserForkRepo(ctx, ctx.Doer, ctx.Repo.Repository)
548548
if err != nil {

templates/admin/config_settings.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
</div>
4242

4343
<h4 class="ui top attached header">
44-
{{ctx.Locale.Tr "admin.config.repository_snippets"}}
44+
{{ctx.Locale.Tr "admin.config.empty_repo_page"}}
4545
</h4>
4646
<div class="ui attached segment">
47-
<form class="ui form form-fetch-action" method="post" action="{{AppSubUrl}}/-/admin/config?key={{.SystemConfig.Repository.SnippetRemoteName.DynKey}}">
47+
<form class="ui form form-fetch-action" method="post" action="{{AppSubUrl}}/-/admin/config?key={{.SystemConfig.Template.GitRemoteName.DynKey}}">
4848
<div class="field" data-field-patched="true">
49-
<label for="remote_name">{{ctx.Locale.Tr "admin.config.repository_snippets.remote_name"}}</label>
50-
<input id="remote_name" name="value" value="{{.SystemConfig.Repository.SnippetRemoteName.Value ctx}}" maxlength="100" dir="auto" placeholder="{{.SystemConfig.Repository.SnippetRemoteName.Def}}">
49+
<label for="remote_name">{{ctx.Locale.Tr "admin.config.empty_repo_page.git_remote_name"}}</label>
50+
<input id="remote_name" name="value" value="{{.SystemConfig.Template.GitRemoteName.Value ctx}}" maxlength="100" dir="auto" placeholder="{{.SystemConfig.Template.GitRemoteName.Def}}">
5151
</div>
5252
<div class="field">
5353
<button class="ui primary button">{{ctx.Locale.Tr "save"}}</button>

templates/repo/empty.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ git init{{if ne .Repository.ObjectFormatName "sha1"}} --object-format={{.Reposit
5151
{{if ne .Repository.DefaultBranch "master"}}git checkout -b {{.Repository.DefaultBranch}}{{end}}
5252
git add README.md
5353
git commit -m "first commit"
54-
git remote add {{.SnippetRemoteName}} <span class="js-clone-url">{{$.CloneButtonOriginLink.HTTPS}}</span>
55-
git push -u {{.SnippetRemoteName}} {{.Repository.DefaultBranch}}</code></pre>
54+
git remote add {{.GitRemoteName}} <span class="js-clone-url">{{$.CloneButtonOriginLink.HTTPS}}</span>
55+
git push -u {{.GitRemoteName}} {{.Repository.DefaultBranch}}</code></pre>
5656
</div>
5757
</div>
5858
<div class="divider"></div>
5959

6060
<div class="item">
6161
<h3>{{ctx.Locale.Tr "repo.push_exist_repo"}}</h3>
6262
<div class="markup">
63-
<pre><code>git remote add {{.SnippetRemoteName}} <span class="js-clone-url">{{$.CloneButtonOriginLink.HTTPS}}</span>
64-
git push -u {{.SnippetRemoteName}} {{.Repository.DefaultBranch}}</code></pre>
63+
<pre><code>git remote add {{.GitRemoteName}} <span class="js-clone-url">{{$.CloneButtonOriginLink.HTTPS}}</span>
64+
git push -u {{.GitRemoteName}} {{.Repository.DefaultBranch}}</code></pre>
6565
</div>
6666
</div>
6767
{{end}}

templates/repo/issue/view_content/pull_merge_box.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
{{end}}
397397

398398
{{if and .Issue.PullRequest.HeadRepo (not .Issue.PullRequest.HasMerged) (not .Issue.IsClosed)}}
399-
{{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "ShowMergeInstructions" .ShowMergeInstructions "SnippetRemoteName" .SnippetRemoteName}}
399+
{{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "ShowMergeInstructions" .ShowMergeInstructions "GitRemoteName" .GitRemoteName}}
400400
{{end}}
401401
</div>
402402
</div>

templates/repo/issue/view_content/pull_merge_instruction.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
{{end}}
1010
<div class="ui secondary segment tw-font-mono">
1111
{{if eq .PullRequest.Flow 0}}
12-
<div>git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}<origin-url data-url="{{.PullRequest.HeadRepo.Link}}"></origin-url>{{else}}{{.SnippetRemoteName}}{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}</div>
12+
<div>git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}<origin-url data-url="{{.PullRequest.HeadRepo.Link}}"></origin-url>{{else}}{{.GitRemoteName}}{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}</div>
1313
{{else}}
14-
<div>git fetch -u {{.SnippetRemoteName}} {{.PullRequest.GetGitHeadRefName}}:{{$localBranch}}</div>
14+
<div>git fetch -u {{.GitRemoteName}} {{.PullRequest.GetGitHeadRefName}}:{{$localBranch}}</div>
1515
{{end}}
1616
<div>git checkout {{$localBranch}}</div>
1717
</div>
@@ -50,7 +50,7 @@
5050
<div>git checkout {{.PullRequest.BaseBranch}}</div>
5151
<div>git merge {{$localBranch}}</div>
5252
</div>
53-
<div>git push {{.SnippetRemoteName}} {{.PullRequest.BaseBranch}}</div>
53+
<div>git push {{.GitRemoteName}} {{.PullRequest.BaseBranch}}</div>
5454
</div>
5555
{{end}}
5656
</div>

0 commit comments

Comments
 (0)