forked from tangled.org/core
this repo has no description

appview: skip fork info query if user is not logged in

Prevents a nil dereference in the repo index route if the user is not
logged in, and hides the fork-sync button.

Fixes: <https://tangled.sh/@tangled.sh/core/issues/108>

Changed files
+7 -3
appview
pages
templates
repo
state
+1 -1
appview/pages/pages.go
···
CommitsTrunc []*object.Commit
TagsTrunc []*types.TagReference
BranchesTrunc []types.Branch
-
ForkInfo types.ForkInfo
types.RepoIndexResponse
HTMLReadme template.HTML
Raw bool
···
CommitsTrunc []*object.Commit
TagsTrunc []*types.TagReference
BranchesTrunc []types.Branch
+
ForkInfo *types.ForkInfo
types.RepoIndexResponse
HTMLReadme template.HTML
Raw bool
+1 -1
appview/pages/templates/repo/index.html
···
{{ end }}
</optgroup>
</select>
-
{{ if .ForkInfo.IsFork }}
{{ $disabled := "" }}
{{ $title := "" }}
{{ if eq .ForkInfo.Status 0 }}
···
{{ end }}
</optgroup>
</select>
+
{{ if and .ForkInfo .ForkInfo.IsFork }}
{{ $disabled := "" }}
{{ $title := "" }}
{{ if eq .ForkInfo.Status 0 }}
+5 -1
appview/state/repo.go
···
RepoIndexResponse: result,
CommitsTrunc: commitsTrunc,
TagsTrunc: tagsTrunc,
-
ForkInfo: *forkInfo,
BranchesTrunc: branchesTrunc,
EmailToDidOrHandle: EmailToDidOrHandle(s, emails),
})
···
w http.ResponseWriter,
user *oauth.User,
) (*types.ForkInfo, error) {
forkInfo := types.ForkInfo{
IsFork: repoInfo.Source != nil,
Status: types.UpToDate,
···
RepoIndexResponse: result,
CommitsTrunc: commitsTrunc,
TagsTrunc: tagsTrunc,
+
ForkInfo: forkInfo,
BranchesTrunc: branchesTrunc,
EmailToDidOrHandle: EmailToDidOrHandle(s, emails),
})
···
w http.ResponseWriter,
user *oauth.User,
) (*types.ForkInfo, error) {
+
if user == nil {
+
return nil, nil
+
}
+
forkInfo := types.ForkInfo{
IsFork: repoInfo.Source != nil,
Status: types.UpToDate,