diff --git a/module/gitea/main.go b/module/gitea/main.go index a5b35d0..87ee0d8 100644 --- a/module/gitea/main.go +++ b/module/gitea/main.go @@ -85,6 +85,7 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util orgSimple[i] = struct{ Name string }{j.UserName} } selOrg := "" + myOrg := "" repoSimple := make([]struct{ Name string }, 0) selRepo := "" selModule := "" @@ -95,10 +96,12 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util if q.Has("org") { selOrg = q.Get("org") var repos []*gitea.Repository - if selOrg == "@me" { + if selOrg == "$me" { + myOrg = myUser.UserName repos, _, err = giteaClient.ListMyRepos(gitea.ListReposOptions{ListOptions: gitea.ListOptions{Page: 0, PageSize: 100}}) } else { - repos, _, err = giteaClient.ListOrgRepos(selOrg, gitea.ListOrgReposOptions{ListOptions: gitea.ListOptions{Page: 0, PageSize: 100}}) + myOrg = selOrg + repos, _, err = giteaClient.ListOrgRepos(myOrg, gitea.ListOrgReposOptions{ListOptions: gitea.ListOptions{Page: 0, PageSize: 100}}) } if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) @@ -111,26 +114,26 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util if q.Has("repo") { selRepo = q.Get("repo") - repo, _, err := giteaClient.GetRepo(selOrg, selRepo) + repo, _, err := giteaClient.GetRepo(myOrg, selRepo) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) return } - refs, _, err := giteaClient.GetRepoRefs(selOrg, selRepo, "heads/"+repo.DefaultBranch) + refs, _, err := giteaClient.GetRepoRefs(myOrg, selRepo, "heads/"+repo.DefaultBranch) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) return } if len(refs) == 1 { ref := refs[0] - commit, _, err := giteaClient.GetSingleCommit(selOrg, selRepo, ref.Object.SHA) + commit, _, err := giteaClient.GetSingleCommit(myOrg, selRepo, ref.Object.SHA) if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) return } selCommitTime = commit.CommitMeta.Created.UTC().Format("20060102150405") selCommitHash = commit.CommitMeta.SHA[:12] - goMod, _, err := giteaClient.GetFile(selOrg, selRepo, ref.Object.SHA, "go.mod") + goMod, _, err := giteaClient.GetFile(myOrg, selRepo, ref.Object.SHA, "go.mod") if err != nil { http.Error(rw, err.Error(), http.StatusInternalServerError) return @@ -153,6 +156,7 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util Username string Orgs []struct{ Name string } Repos []struct{ Name string } + MyOrg string SelOrg string ShowOrg bool SelModule string @@ -163,9 +167,10 @@ func (m *Module) homepage(rw http.ResponseWriter, req *http.Request, state *util Username: myUser.UserName, Orgs: orgSimple, Repos: repoSimple, + MyOrg: myOrg, SelOrg: selOrg, SelModule: selModule, - ShowOrg: selOrg != "", + ShowOrg: myOrg != "", ShowRepo: selModule != "", CommitTime: selCommitTime, CommitHash: selCommitHash, diff --git a/module/gitea/pages/index.go.html b/module/gitea/pages/index.go.html index 0efa997..8312438 100644 --- a/module/gitea/pages/index.go.html +++ b/module/gitea/pages/index.go.html @@ -28,7 +28,7 @@
Select repository source: