mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Simplify context ref name (#33267)
This commit is contained in:
		| @@ -193,11 +193,11 @@ func CreateBranch(ctx *context.Context) { | |||||||
|  |  | ||||||
| 	if form.CreateTag { | 	if form.CreateTag { | ||||||
| 		target := ctx.Repo.CommitID | 		target := ctx.Repo.CommitID | ||||||
| 		if ctx.Repo.IsViewBranch { | 		if ctx.Repo.RefFullName.IsBranch() { | ||||||
| 			target = ctx.Repo.BranchName | 			target = ctx.Repo.BranchName | ||||||
| 		} | 		} | ||||||
| 		err = release_service.CreateNewTag(ctx, ctx.Doer, ctx.Repo.Repository, target, form.NewBranchName, "") | 		err = release_service.CreateNewTag(ctx, ctx.Doer, ctx.Repo.Repository, target, form.NewBranchName, "") | ||||||
| 	} else if ctx.Repo.IsViewBranch { | 	} else if ctx.Repo.RefFullName.IsBranch() { | ||||||
| 		err = repo_service.CreateNewBranch(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.BranchName, form.NewBranchName) | 		err = repo_service.CreateNewBranch(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.BranchName, form.NewBranchName) | ||||||
| 	} else { | 	} else { | ||||||
| 		err = repo_service.CreateNewBranchFromCommit(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.CommitID, form.NewBranchName) | 		err = repo_service.CreateNewBranchFromCommit(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.CommitID, form.NewBranchName) | ||||||
|   | |||||||
| @@ -390,12 +390,6 @@ func Diff(ctx *context.Context) { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ctx.Data["BranchName"], err = commit.GetBranchName() |  | ||||||
| 	if err != nil { |  | ||||||
| 		ctx.ServerError("commit.GetBranchName", err) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	ctx.HTML(http.StatusOK, tplCommitPage) | 	ctx.HTML(http.StatusOK, tplCommitPage) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -148,8 +148,6 @@ func getReleaseInfos(ctx *context.Context, opts *repo_model.FindReleasesOptions) | |||||||
| func Releases(ctx *context.Context) { | func Releases(ctx *context.Context) { | ||||||
| 	ctx.Data["PageIsReleaseList"] = true | 	ctx.Data["PageIsReleaseList"] = true | ||||||
| 	ctx.Data["Title"] = ctx.Tr("repo.release.releases") | 	ctx.Data["Title"] = ctx.Tr("repo.release.releases") | ||||||
| 	ctx.Data["IsViewBranch"] = false |  | ||||||
| 	ctx.Data["IsViewTag"] = true |  | ||||||
|  |  | ||||||
| 	listOptions := db.ListOptions{ | 	listOptions := db.ListOptions{ | ||||||
| 		Page:     ctx.FormInt("page"), | 		Page:     ctx.FormInt("page"), | ||||||
| @@ -194,8 +192,6 @@ func Releases(ctx *context.Context) { | |||||||
| func TagsList(ctx *context.Context) { | func TagsList(ctx *context.Context) { | ||||||
| 	ctx.Data["PageIsTagList"] = true | 	ctx.Data["PageIsTagList"] = true | ||||||
| 	ctx.Data["Title"] = ctx.Tr("repo.release.tags") | 	ctx.Data["Title"] = ctx.Tr("repo.release.tags") | ||||||
| 	ctx.Data["IsViewBranch"] = false |  | ||||||
| 	ctx.Data["IsViewTag"] = true |  | ||||||
| 	ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived | 	ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived | ||||||
|  |  | ||||||
| 	namePattern := ctx.FormTrim("q") | 	namePattern := ctx.FormTrim("q") | ||||||
|   | |||||||
| @@ -232,7 +232,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { | |||||||
| 					ctx.Data["CanEditFile"] = true | 					ctx.Data["CanEditFile"] = true | ||||||
| 					ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file") | 					ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.edit_this_file") | ||||||
| 				} | 				} | ||||||
| 			} else if !ctx.Repo.IsViewBranch { | 			} else if !ctx.Repo.RefFullName.IsBranch() { | ||||||
| 				ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch") | 				ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch") | ||||||
| 			} else if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) { | 			} else if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) { | ||||||
| 				ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit") | 				ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.fork_before_edit") | ||||||
| @@ -305,7 +305,7 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { | |||||||
| 			ctx.Data["CanDeleteFile"] = true | 			ctx.Data["CanDeleteFile"] = true | ||||||
| 			ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file") | 			ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file") | ||||||
| 		} | 		} | ||||||
| 	} else if !ctx.Repo.IsViewBranch { | 	} else if !ctx.Repo.RefFullName.IsBranch() { | ||||||
| 		ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch") | 		ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch") | ||||||
| 	} else if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) { | 	} else if !ctx.Repo.CanWriteToBranch(ctx, ctx.Doer, ctx.Repo.BranchName) { | ||||||
| 		ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access") | 		ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access") | ||||||
|   | |||||||
| @@ -178,7 +178,7 @@ func prepareHomeSidebarLatestRelease(ctx *context.Context) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func prepareUpstreamDivergingInfo(ctx *context.Context) { | func prepareUpstreamDivergingInfo(ctx *context.Context) { | ||||||
| 	if !ctx.Repo.Repository.IsFork || !ctx.Repo.IsViewBranch || ctx.Repo.TreePath != "" { | 	if !ctx.Repo.Repository.IsFork || !ctx.Repo.RefFullName.IsBranch() || ctx.Repo.TreePath != "" { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	upstreamDivergingInfo, err := repo_service.GetUpstreamDivergingInfo(ctx, ctx.Repo.Repository, ctx.Repo.BranchName) | 	upstreamDivergingInfo, err := repo_service.GetUpstreamDivergingInfo(ctx, ctx.Repo.Repository, ctx.Repo.BranchName) | ||||||
|   | |||||||
| @@ -53,20 +53,15 @@ type Repository struct { | |||||||
| 	RepoLink string | 	RepoLink string | ||||||
| 	GitRepo  *git.Repository | 	GitRepo  *git.Repository | ||||||
|  |  | ||||||
| 	// these fields indicate the current ref type, for example: ".../src/branch/master" means IsViewBranch=true | 	// RefFullName is the full ref name that the user is viewing | ||||||
| 	IsViewBranch bool |  | ||||||
| 	IsViewTag    bool |  | ||||||
| 	IsViewCommit bool |  | ||||||
|  |  | ||||||
| 	RefFullName git.RefName | 	RefFullName git.RefName | ||||||
| 	BranchName  string | 	BranchName  string // it is the RefFullName's short name if its type is "branch" | ||||||
| 	TagName     string | 	TagName     string // it is the RefFullName's short name if its type is "tag" | ||||||
| 	TreePath    string | 	TreePath    string | ||||||
|  |  | ||||||
| 	// Commit it is always set to the commit for the branch or tag | 	// Commit it is always set to the commit for the branch or tag, or just the commit that the user is viewing | ||||||
| 	Commit   *git.Commit | 	Commit       *git.Commit | ||||||
| 	CommitID string | 	CommitID     string | ||||||
|  |  | ||||||
| 	CommitsCount int64 | 	CommitsCount int64 | ||||||
|  |  | ||||||
| 	PullRequest *PullRequest | 	PullRequest *PullRequest | ||||||
| @@ -79,7 +74,7 @@ func (r *Repository) CanWriteToBranch(ctx context.Context, user *user_model.User | |||||||
|  |  | ||||||
| // CanEnableEditor returns true if repository is editable and user has proper access level. | // CanEnableEditor returns true if repository is editable and user has proper access level. | ||||||
| func (r *Repository) CanEnableEditor(ctx context.Context, user *user_model.User) bool { | func (r *Repository) CanEnableEditor(ctx context.Context, user *user_model.User) bool { | ||||||
| 	return r.IsViewBranch && r.CanWriteToBranch(ctx, user, r.BranchName) && r.Repository.CanEnableEditor() && !r.Repository.IsArchived | 	return r.RefFullName.IsBranch() && r.CanWriteToBranch(ctx, user, r.BranchName) && r.Repository.CanEnableEditor() && !r.Repository.IsArchived | ||||||
| } | } | ||||||
|  |  | ||||||
| // CanCreateBranch returns true if repository is editable and user has proper access level. | // CanCreateBranch returns true if repository is editable and user has proper access level. | ||||||
| @@ -174,15 +169,9 @@ func (r *Repository) GetCommitsCount() (int64, error) { | |||||||
| 	if r.Commit == nil { | 	if r.Commit == nil { | ||||||
| 		return 0, nil | 		return 0, nil | ||||||
| 	} | 	} | ||||||
| 	var contextName string | 	contextName := r.RefFullName.ShortName() | ||||||
| 	if r.IsViewBranch { | 	isRef := r.RefFullName.IsBranch() || r.RefFullName.IsTag() | ||||||
| 		contextName = r.BranchName | 	return cache.GetInt64(r.Repository.GetCommitsCountCacheKey(contextName, isRef), func() (int64, error) { | ||||||
| 	} else if r.IsViewTag { |  | ||||||
| 		contextName = r.TagName |  | ||||||
| 	} else { |  | ||||||
| 		contextName = r.CommitID |  | ||||||
| 	} |  | ||||||
| 	return cache.GetInt64(r.Repository.GetCommitsCountCacheKey(contextName, r.IsViewBranch || r.IsViewTag), func() (int64, error) { |  | ||||||
| 		return r.Commit.CommitsCount() | 		return r.Commit.CommitsCount() | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
| @@ -798,7 +787,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) { | |||||||
| 		// Empty repository does not have reference information. | 		// Empty repository does not have reference information. | ||||||
| 		if ctx.Repo.Repository.IsEmpty { | 		if ctx.Repo.Repository.IsEmpty { | ||||||
| 			// assume the user is viewing the (non-existent) default branch | 			// assume the user is viewing the (non-existent) default branch | ||||||
| 			ctx.Repo.IsViewBranch = true |  | ||||||
| 			ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch | 			ctx.Repo.BranchName = ctx.Repo.Repository.DefaultBranch | ||||||
| 			ctx.Repo.RefFullName = git.RefNameFromBranch(ctx.Repo.BranchName) | 			ctx.Repo.RefFullName = git.RefNameFromBranch(ctx.Repo.BranchName) | ||||||
| 			// these variables are used by the template to "add/upload" new files | 			// these variables are used by the template to "add/upload" new files | ||||||
| @@ -834,7 +822,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) { | |||||||
| 				ctx.ServerError("GetBranchCommit", err) | 				ctx.ServerError("GetBranchCommit", err) | ||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 			ctx.Repo.IsViewBranch = true |  | ||||||
| 		} else { // there is a path in request | 		} else { // there is a path in request | ||||||
| 			guessLegacyPath := refType == "" | 			guessLegacyPath := refType == "" | ||||||
| 			if guessLegacyPath { | 			if guessLegacyPath { | ||||||
| @@ -853,7 +840,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if refType == git.RefTypeBranch && ctx.Repo.GitRepo.IsBranchExist(refShortName) { | 			if refType == git.RefTypeBranch && ctx.Repo.GitRepo.IsBranchExist(refShortName) { | ||||||
| 				ctx.Repo.IsViewBranch = true |  | ||||||
| 				ctx.Repo.BranchName = refShortName | 				ctx.Repo.BranchName = refShortName | ||||||
| 				ctx.Repo.RefFullName = git.RefNameFromBranch(refShortName) | 				ctx.Repo.RefFullName = git.RefNameFromBranch(refShortName) | ||||||
|  |  | ||||||
| @@ -864,7 +850,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) { | |||||||
| 				} | 				} | ||||||
| 				ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() | 				ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() | ||||||
| 			} else if refType == git.RefTypeTag && ctx.Repo.GitRepo.IsTagExist(refShortName) { | 			} else if refType == git.RefTypeTag && ctx.Repo.GitRepo.IsTagExist(refShortName) { | ||||||
| 				ctx.Repo.IsViewTag = true |  | ||||||
| 				ctx.Repo.RefFullName = git.RefNameFromTag(refShortName) | 				ctx.Repo.RefFullName = git.RefNameFromTag(refShortName) | ||||||
| 				ctx.Repo.TagName = refShortName | 				ctx.Repo.TagName = refShortName | ||||||
|  |  | ||||||
| @@ -879,7 +864,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) { | |||||||
| 				} | 				} | ||||||
| 				ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() | 				ctx.Repo.CommitID = ctx.Repo.Commit.ID.String() | ||||||
| 			} else if git.IsStringLikelyCommitID(ctx.Repo.GetObjectFormat(), refShortName, 7) { | 			} else if git.IsStringLikelyCommitID(ctx.Repo.GetObjectFormat(), refShortName, 7) { | ||||||
| 				ctx.Repo.IsViewCommit = true |  | ||||||
| 				ctx.Repo.RefFullName = git.RefNameFromCommit(refShortName) | 				ctx.Repo.RefFullName = git.RefNameFromCommit(refShortName) | ||||||
| 				ctx.Repo.CommitID = refShortName | 				ctx.Repo.CommitID = refShortName | ||||||
|  |  | ||||||
| @@ -915,13 +899,10 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) { | |||||||
| 		ctx.Data["RefTypeNameSubURL"] = ctx.Repo.RefTypeNameSubURL() | 		ctx.Data["RefTypeNameSubURL"] = ctx.Repo.RefTypeNameSubURL() | ||||||
| 		ctx.Data["TreePath"] = ctx.Repo.TreePath | 		ctx.Data["TreePath"] = ctx.Repo.TreePath | ||||||
|  |  | ||||||
| 		ctx.Data["IsViewBranch"] = ctx.Repo.IsViewBranch |  | ||||||
| 		ctx.Data["BranchName"] = ctx.Repo.BranchName | 		ctx.Data["BranchName"] = ctx.Repo.BranchName | ||||||
|  |  | ||||||
| 		ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag |  | ||||||
| 		ctx.Data["TagName"] = ctx.Repo.TagName | 		ctx.Data["TagName"] = ctx.Repo.TagName | ||||||
|  |  | ||||||
| 		ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit |  | ||||||
| 		ctx.Data["CommitID"] = ctx.Repo.CommitID | 		ctx.Data["CommitID"] = ctx.Repo.CommitID | ||||||
|  |  | ||||||
| 		ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef | 		ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ | |||||||
| 		<div class="file-header-right file-actions tw-flex tw-items-center tw-flex-wrap"> | 		<div class="file-header-right file-actions tw-flex tw-items-center tw-flex-wrap"> | ||||||
| 			<div class="ui buttons"> | 			<div class="ui buttons"> | ||||||
| 				<a class="ui tiny button" href="{{$.RawFileLink}}">{{ctx.Locale.Tr "repo.file_raw"}}</a> | 				<a class="ui tiny button" href="{{$.RawFileLink}}">{{ctx.Locale.Tr "repo.file_raw"}}</a> | ||||||
| 				{{if not .IsViewCommit}} | 				{{if or .RefFullName.IsBranch .RefFullName.IsTag}} | ||||||
| 					<a class="ui tiny button" href="{{.RepoLink}}/src/commit/{{.CommitID | PathEscape}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.file_permalink"}}</a> | 					<a class="ui tiny button" href="{{.RepoLink}}/src/commit/{{.CommitID | PathEscape}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.file_permalink"}}</a> | ||||||
| 				{{end}} | 				{{end}} | ||||||
| 				<a class="ui tiny button" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.normal_view"}}</a> | 				<a class="ui tiny button" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.normal_view"}}</a> | ||||||
|   | |||||||
| @@ -54,13 +54,11 @@ | |||||||
| 											<p id="cherry-pick-content" class="branch-dropdown"></p> | 											<p id="cherry-pick-content" class="branch-dropdown"></p> | ||||||
|  |  | ||||||
| 											<form method="get"> | 											<form method="get"> | ||||||
| 												{{/*FIXME: CurrentRefShortName seems not making sense here (old code), |  | ||||||
| 												because the "commit page" has no "$.BranchName" info, so only using DefaultBranch should be enough */}} |  | ||||||
| 												{{template "repo/branch_dropdown" dict | 												{{template "repo/branch_dropdown" dict | ||||||
| 													"Repository" .Repository | 													"Repository" .Repository | ||||||
| 													"ShowTabBranches" true | 													"ShowTabBranches" true | ||||||
| 													"CurrentRefType" "branch" | 													"CurrentRefType" "branch" | ||||||
| 													"CurrentRefShortName" (or $.BranchName $.Repository.DefaultBranch) | 													"CurrentRefShortName" $.Repository.DefaultBranch | ||||||
| 													"RefFormActionTemplate" (print "{RepoLink}/_cherrypick/" .CommitID "/{RefShortName}") | 													"RefFormActionTemplate" (print "{RepoLink}/_cherrypick/" .CommitID "/{RefShortName}") | ||||||
| 												}} | 												}} | ||||||
| 												<input type="hidden" id="cherry-pick-type" name="cherry-pick-type"><br> | 												<input type="hidden" id="cherry-pick-type" name="cherry-pick-type"><br> | ||||||
|   | |||||||
| @@ -5,24 +5,13 @@ | |||||||
| 		{{template "repo/sub_menu" .}} | 		{{template "repo/sub_menu" .}} | ||||||
| 		<div class="repo-button-row"> | 		<div class="repo-button-row"> | ||||||
| 			<div class="repo-button-row-left"> | 			<div class="repo-button-row-left"> | ||||||
| 				{{- /* for /owner/repo/commits/branch/the-name */ -}} | 				{{- /* for /owner/repo/commits/{RefType}/{RefShortName} */ -}} | ||||||
| 				{{- $branchDropdownCurrentRefType := "branch" -}} |  | ||||||
| 				{{- $branchDropdownCurrentRefShortName := .BranchName -}} |  | ||||||
| 				{{- if .IsViewTag -}} |  | ||||||
| 					{{- /* for /owner/repo/commits/tag/the-name */ -}} |  | ||||||
| 					{{- $branchDropdownCurrentRefType = "tag" -}} |  | ||||||
| 					{{- $branchDropdownCurrentRefShortName = .TagName -}} |  | ||||||
| 				{{- else if .IsViewCommit -}} |  | ||||||
| 					{{- /* for /owner/repo/commits/commit/000000 */ -}} |  | ||||||
| 					{{- $branchDropdownCurrentRefType = "commit" -}} |  | ||||||
| 					{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}} |  | ||||||
| 				{{- end -}} |  | ||||||
| 				{{- template "repo/branch_dropdown" dict | 				{{- template "repo/branch_dropdown" dict | ||||||
| 					"Repository" .Repository | 					"Repository" .Repository | ||||||
| 					"ShowTabBranches" true | 					"ShowTabBranches" true | ||||||
| 					"ShowTabTags" true | 					"ShowTabTags" true | ||||||
| 					"CurrentRefType" $branchDropdownCurrentRefType | 					"CurrentRefType" .RefFullName.RefType | ||||||
| 					"CurrentRefShortName" $branchDropdownCurrentRefShortName | 					"CurrentRefShortName" .RefFullName.ShortName | ||||||
| 					"CurrentTreePath" .TreePath | 					"CurrentTreePath" .TreePath | ||||||
| 					"RefLinkTemplate" "{RepoLink}/commits/{RefType}/{RefShortName}/{TreePath}" | 					"RefLinkTemplate" "{RepoLink}/commits/{RefType}/{RefShortName}/{TreePath}" | ||||||
| 					"AllowCreateNewRef" .CanCreateBranch | 					"AllowCreateNewRef" .CanCreateBranch | ||||||
|   | |||||||
| @@ -24,30 +24,19 @@ | |||||||
| 				{{template "repo/sub_menu" .}} | 				{{template "repo/sub_menu" .}} | ||||||
| 				<div class="repo-button-row"> | 				<div class="repo-button-row"> | ||||||
| 					<div class="repo-button-row-left"> | 					<div class="repo-button-row-left"> | ||||||
| 						{{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}} | 						{{- /* for repo home (default branch) and /owner/repo/src/{RefType}/{RefShortName} */ -}} | ||||||
| 						{{- $branchDropdownCurrentRefType := "branch" -}} |  | ||||||
| 						{{- $branchDropdownCurrentRefShortName := .BranchName -}} |  | ||||||
| 						{{- if .IsViewTag -}} |  | ||||||
| 							{{- /* for /owner/repo/src/tag/the-name */ -}} |  | ||||||
| 							{{- $branchDropdownCurrentRefType = "tag" -}} |  | ||||||
| 							{{- $branchDropdownCurrentRefShortName = .TagName -}} |  | ||||||
| 						{{- else if .IsViewCommit -}} |  | ||||||
| 							{{- /* for /owner/repo/src/commit/000000 */ -}} |  | ||||||
| 							{{- $branchDropdownCurrentRefType = "commit" -}} |  | ||||||
| 							{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}} |  | ||||||
| 						{{- end -}} |  | ||||||
| 						{{- template "repo/branch_dropdown" dict | 						{{- template "repo/branch_dropdown" dict | ||||||
| 							"Repository" .Repository | 							"Repository" .Repository | ||||||
| 							"ShowTabBranches" true | 							"ShowTabBranches" true | ||||||
| 							"ShowTabTags" true | 							"ShowTabTags" true | ||||||
| 							"CurrentRefType" $branchDropdownCurrentRefType | 							"CurrentRefType" .RefFullName.RefType | ||||||
| 							"CurrentRefShortName" $branchDropdownCurrentRefShortName | 							"CurrentRefShortName" .RefFullName.ShortName | ||||||
| 							"CurrentTreePath" .TreePath | 							"CurrentTreePath" .TreePath | ||||||
| 							"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}" | 							"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}" | ||||||
| 							"AllowCreateNewRef" .CanCreateBranch | 							"AllowCreateNewRef" .CanCreateBranch | ||||||
| 							"ShowViewAllRefsEntry" true | 							"ShowViewAllRefsEntry" true | ||||||
| 						-}} | 						-}} | ||||||
| 						{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} | 						{{if and .CanCompareOrPull .RefFullName.IsBranch (not .Repository.IsArchived)}} | ||||||
| 							{{$cmpBranch := ""}} | 							{{$cmpBranch := ""}} | ||||||
| 							{{if ne .Repository.ID .BaseRepo.ID}} | 							{{if ne .Repository.ID .BaseRepo.ID}} | ||||||
| 								{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}} | 								{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}} | ||||||
| @@ -65,7 +54,7 @@ | |||||||
| 							<a href="{{.Repository.Link}}/find/{{.RefTypeNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a> | 							<a href="{{.Repository.Link}}/find/{{.RefTypeNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a> | ||||||
| 						{{end}} | 						{{end}} | ||||||
|  |  | ||||||
| 						{{if and .CanWriteCode .IsViewBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}} | 						{{if and .CanWriteCode .RefFullName.IsBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}} | ||||||
| 							<button class="ui dropdown basic compact jump button"{{if not .Repository.CanEnableEditor}} disabled{{end}}> | 							<button class="ui dropdown basic compact jump button"{{if not .Repository.CanEnableEditor}} disabled{{end}}> | ||||||
| 								{{ctx.Locale.Tr "repo.editor.add_file"}} | 								{{ctx.Locale.Tr "repo.editor.add_file"}} | ||||||
| 								{{svg "octicon-triangle-down" 14 "dropdown icon"}} | 								{{svg "octicon-triangle-down" 14 "dropdown icon"}} | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ | |||||||
| 								"Repository" $.Repository | 								"Repository" $.Repository | ||||||
| 								"ShowTabTags" true | 								"ShowTabTags" true | ||||||
| 								"DropdownFixedText" (ctx.Locale.Tr "repo.release.compare") | 								"DropdownFixedText" (ctx.Locale.Tr "repo.release.compare") | ||||||
| 								"RefLinkTemplate" (print "{RepoLink}/compare/{RefShortName}..." (PathEscapeSegments $compareTarget)) | 								"RefLinkTemplate" (print "{RepoLink}/compare/{RefShortName}" "..." (PathEscapeSegments $compareTarget)) | ||||||
| 							}} | 							}} | ||||||
| 						{{end}} | 						{{end}} | ||||||
| 					</div> | 					</div> | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ | |||||||
| 			{{if not .ReadmeInList}} | 			{{if not .ReadmeInList}} | ||||||
| 				<div class="ui buttons tw-mr-1"> | 				<div class="ui buttons tw-mr-1"> | ||||||
| 					<a class="ui mini basic button" href="{{$.RawFileLink}}">{{ctx.Locale.Tr "repo.file_raw"}}</a> | 					<a class="ui mini basic button" href="{{$.RawFileLink}}">{{ctx.Locale.Tr "repo.file_raw"}}</a> | ||||||
| 					{{if not .IsViewCommit}} | 					{{if or .RefFullName.IsBranch .RefFullName.IsTag}} | ||||||
| 						<a class="ui mini basic button" href="{{.RepoLink}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.file_permalink"}}</a> | 						<a class="ui mini basic button" href="{{.RepoLink}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.file_permalink"}}</a> | ||||||
| 					{{end}} | 					{{end}} | ||||||
| 					{{if .IsRepresentableAsText}} | 					{{if .IsRepresentableAsText}} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user