| @@ -243,17 +243,20 @@ type repoPage struct { |
| 243 | 243 | Repo store.Repo |
| 244 | 244 | Ref string |
| 245 | 245 | CloneURL string |
| 246 | | Dir string |
| 247 | | Tab string // active tab in the repo header |
| 248 | | Topics []string |
| 249 | | Pinned bool // by the viewer |
| 250 | | Marked bool // bookmarked by the viewer |
| 251 | | Watch string // the viewer's watch state: watching, muted, or "" |
| 252 | | HasWiki bool |
| 253 | | Host string |
| 254 | | Mirrors []mirrorLine // repo admins only |
| 255 | | CanAdmin bool // gates the settings tab |
| 256 | | Feed string // Atom feed for this page, if it has one |
| 246 | // SSHCloneURL is the same repository over the SSH transport, which is |
| 247 | // the one a push needs. |
| 248 | SSHCloneURL string |
| 249 | Dir string |
| 250 | Tab string // active tab in the repo header |
| 251 | Topics []string |
| 252 | Pinned bool // by the viewer |
| 253 | Marked bool // bookmarked by the viewer |
| 254 | Watch string // the viewer's watch state: watching, muted, or "" |
| 255 | HasWiki bool |
| 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 | 260 | // OpenIssues and OpenMRs are the counts on the header tabs. |
| 258 | 261 | OpenIssues int |
| 259 | 262 | OpenMRs int |
| @@ -331,22 +334,23 @@ func (s *Server) repoFor(w http.ResponseWriter, r *http.Request, ref string) (re |
| 331 | 334 | } |
| 332 | 335 | openIssues, openMRs := s.st.OpenCounts(repo.ID) |
| 333 | 336 | return repoPage{ |
| 334 | | basePage: s.baseFor(viewer), |
| 335 | | CanAdmin: canAdmin, |
| 336 | | Mirrors: mirrors, |
| 337 | | Pinned: pinned, |
| 338 | | Marked: marked, |
| 339 | | Watch: watch, |
| 340 | | HasWiki: s.hasWiki(repo), |
| 341 | | Host: s.cfg.SiteHost(), |
| 342 | | Desc: gitutil.ReadDescription(control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name)), |
| 343 | | Repo: repo, |
| 344 | | Ref: ref, |
| 345 | | CloneURL: s.cfg.Server.SiteURL + "/" + repo.Path() + ".git", |
| 346 | | Dir: control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name), |
| 347 | | Topics: topics, |
| 348 | | OpenIssues: openIssues, |
| 349 | | OpenMRs: openMRs, |
| 337 | basePage: s.baseFor(viewer), |
| 338 | CanAdmin: canAdmin, |
| 339 | Mirrors: mirrors, |
| 340 | Pinned: pinned, |
| 341 | Marked: marked, |
| 342 | Watch: watch, |
| 343 | HasWiki: s.hasWiki(repo), |
| 344 | Host: s.cfg.SiteHost(), |
| 345 | Desc: gitutil.ReadDescription(control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name)), |
| 346 | Repo: repo, |
| 347 | Ref: ref, |
| 348 | CloneURL: s.cfg.Server.SiteURL + "/" + repo.Path() + ".git", |
| 349 | SSHCloneURL: s.sshCloneURL(repo), |
| 350 | Dir: control.RepoDir(s.cfg.Server.Root, repo.OwnerName, repo.Name), |
| 351 | Topics: topics, |
| 352 | OpenIssues: openIssues, |
| 353 | OpenMRs: openMRs, |
| 350 | 354 | }, true |
| 351 | 355 | } |
| 352 | 356 | |
| @@ -1951,9 +1955,26 @@ func (s *Server) mr(w http.ResponseWriter, r *http.Request) { |
| 1951 | 1955 | StackedOn *store.MR |
| 1952 | 1956 | Stacked []store.MR |
| 1953 | 1957 | Gates *control.GatesOut |
| 1958 | SourceGone bool |
| 1954 | 1959 | }{p, m, view, md(m.Body, m.BodyFormat), checks, combined, renderComments(comments, md), |
| 1955 | 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 | 1980 | func (s *Server) refs(w http.ResponseWriter, r *http.Request) { |
| @@ -2007,3 +2028,13 @@ type reviewRow struct { |
| 2007 | 2028 | store.MRReview |
| 2008 | 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 | } |