| @@ -243,17 +243,20 @@ type repoPage struct { |
| 243 | Repo store.Repo |
243 | Repo store.Repo |
| 244 | Ref string |
244 | Ref string |
| 245 | CloneURL string |
245 | CloneURL string |
| 246 | Dir string |
246 | // SSHCloneURL is the same repository over the SSH transport, which is |
| 247 | Tab string // active tab in the repo header |
247 | // the one a push needs. |
| 248 | Topics []string |
248 | SSHCloneURL string |
| 249 | Pinned bool // by the viewer |
249 | Dir string |
| 250 | Marked bool // bookmarked by the viewer |
250 | Tab string // active tab in the repo header |
| 251 | Watch string // the viewer's watch state: watching, muted, or "" |
251 | Topics []string |
| 252 | HasWiki bool |
252 | Pinned bool // by the viewer |
| 253 | Host string |
253 | Marked bool // bookmarked by the viewer |
| 254 | Mirrors []mirrorLine // repo admins only |
254 | Watch string // the viewer's watch state: watching, muted, or "" |
| 255 | CanAdmin bool // gates the settings tab |
255 | HasWiki bool |
| 256 | Feed string // Atom feed for this page, if it has one |
256 | Host string |
| |
257 | Mirrors []mirrorLine // repo admins only |
| |
258 | CanAdmin bool // gates the settings tab |
| |
259 | Feed string // Atom feed for this page, if it has one |
| 257 | // OpenIssues and OpenMRs are the counts on the header tabs. |
260 | // OpenIssues and OpenMRs are the counts on the header tabs. |
| 258 | OpenIssues int |
261 | OpenIssues int |
| 259 | OpenMRs int |
262 | OpenMRs int |
| @@ -331,22 +334,23 @@ func (s *Server) repoFor(w http.ResponseWriter, r *http.Request, ref string) (re |
| 331 | } |
334 | } |
| 332 | openIssues, openMRs := s.st.OpenCounts(repo.ID) |
335 | openIssues, openMRs := s.st.OpenCounts(repo.ID) |
| 333 | return repoPage{ |
336 | return repoPage{ |
| 334 | basePage: s.baseFor(viewer), |
337 | basePage: s.baseFor(viewer), |
| 335 | CanAdmin: canAdmin, |
338 | CanAdmin: canAdmin, |
| 336 | Mirrors: mirrors, |
339 | Mirrors: mirrors, |
| 337 | Pinned: pinned, |
340 | Pinned: pinned, |
| 338 | Marked: marked, |
341 | Marked: marked, |
| 339 | Watch: watch, |
342 | Watch: watch, |
| 340 | HasWiki: s.hasWiki(repo), |
343 | HasWiki: s.hasWiki(repo), |
| 341 | Host: s.cfg.SiteHost(), |
344 | Host: s.cfg.SiteHost(), |
| 342 | Desc: gitutil.ReadDescription(control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name)), |
345 | Desc: gitutil.ReadDescription(control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name)), |
| 343 | Repo: repo, |
346 | Repo: repo, |
| 344 | Ref: ref, |
347 | Ref: ref, |
| 345 | CloneURL: s.cfg.Server.SiteURL + "/" + repo.Path() + ".git", |
348 | CloneURL: s.cfg.Server.SiteURL + "/" + repo.Path() + ".git", |
| 346 | Dir: control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name), |
349 | SSHCloneURL: s.sshCloneURL(repo), |
| 347 | Topics: topics, |
350 | Dir: control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name), |
| 348 | OpenIssues: openIssues, |
351 | Topics: topics, |
| 349 | OpenMRs: openMRs, |
352 | OpenIssues: openIssues, |
| |
353 | OpenMRs: openMRs, |
| 350 | }, true |
354 | }, true |
| 351 | } |
355 | } |
| 352 | |
356 | |
| @@ -1951,9 +1955,26 @@ func (s *Server) mr(w http.ResponseWriter, r *http.Request) { |
| 1951 | StackedOn *store.MR |
1955 | StackedOn *store.MR |
| 1952 | Stacked []store.MR |
1956 | Stacked []store.MR |
| 1953 | Gates *control.GatesOut |
1957 | Gates *control.GatesOut |
| |
1958 | SourceGone bool |
| 1954 | }{p, m, view, md(m.Body, m.BodyFormat), checks, combined, renderComments(comments, md), |
1959 | }{p, m, view, md(m.Body, m.BodyFormat), checks, combined, renderComments(comments, md), |
| 1955 | reviewRows, files, diffTruncated, stat, commits, commitsTotal, branches, s.canEditItem(r, p.Repo, m.Author), |
1960 | reviewRows, files, diffTruncated, stat, commits, commitsTotal, branches, s.canEditItem(r, p.Repo, m.Author), |
| 1956 | canWrite, unresolved, revisions, s.takeFlash(w, r), detachedThreads, stackedOn, stacked, gates}) |
1961 | canWrite, unresolved, revisions, s.takeFlash(w, r), detachedThreads, stackedOn, stacked, gates, |
| |
1962 | sourceGone(p, m)}) |
| |
1963 | } |
| |
1964 | |
| |
1965 | // sourceGone reports whether an MR's source branch no longer exists: the |
| |
1966 | // push hook marks a deleted branch on an open MR, and a merged or closed |
| |
1967 | // one is checked here. A fork's branch lives in another repository and |
| |
1968 | // is left to the recorded state. |
| |
1969 | func sourceGone(p repoPage, m store.MR) bool { |
| |
1970 | if m.State == "source_gone" { |
| |
1971 | return true |
| |
1972 | } |
| |
1973 | if m.SourceRepoID != p.Repo.ID { |
| |
1974 | return false |
| |
1975 | } |
| |
1976 | _, err := gitutil.ResolveRef(p.Dir, "refs/heads/"+m.SourceRef) |
| |
1977 | return err != nil |
| 1957 | } |
1978 | } |
| 1958 | |
1979 | |
| 1959 | func (s *Server) refs(w http.ResponseWriter, r *http.Request) { |
1980 | func (s *Server) refs(w http.ResponseWriter, r *http.Request) { |
| @@ -2007,3 +2028,13 @@ type reviewRow struct { |
| 2007 | store.MRReview |
2028 | store.MRReview |
| 2008 | Counts bool |
2029 | Counts bool |
| 2009 | } |
2030 | } |
| |
2031 | |
| |
2032 | // sshCloneURL is the SSH clone URL for a repository, with the port only |
| |
2033 | // when it is not the default. |
| |
2034 | func (s *Server) sshCloneURL(repo store.Repo) string { |
| |
2035 | host := s.cfg.SiteHost() |
| |
2036 | if s.cfg.SSH.Port != 22 { |
| |
2037 | host += ":" + strconv.Itoa(s.cfg.SSH.Port) |
| |
2038 | } |
| |
2039 | return "ssh://git@" + host + "/" + repo.Path() + ".git" |
| |
2040 | } |