repos / git-pr

a self-hosted git collaboration server
git clone https://github.com/picosh/git-pr.git

commit
e76ab98
parent
821d0e5
author
Eric Bower
date
2024-06-24 22:08:20 -0400 EDT
chore: cleanup
3 files changed,  +20, -2
M web.go
M tmpl/pr-header.html
+1, -1
1@@ -15,7 +15,7 @@
2     <summary>Help</summary>
3     <div class="group">
4       <pre class="m-0"># add changes to patch request
5-git format-patch main --stdout | ssh pr.pico.sh pr add {{.Pr.ID}}</pre>
6+git format-patch {{.Branch}} --stdout | ssh pr.pico.sh pr add {{.Pr.ID}}</pre>
7       <pre class="m-0"># checkout all patches
8 ssh pr.pico.sh pr print {{.Pr.ID}} | git am -3</pre>
9       <pre class="m-0"># checkout specific patch
M tmpl/repo-detail.html
+11, -1
 1@@ -19,7 +19,7 @@
 2     <details>
 3       <summary>Help</summary>
 4       <pre class="m-0"># submit a new patch request
 5-git format-patch main --stdout | ssh pr.pico.sh pr create {{.ID}}</pre>
 6+git format-patch {{.Branch}} --stdout | ssh pr.pico.sh pr create {{.ID}}</pre>
 7     </details>
 8 	</div>
 9 </header>
10@@ -27,6 +27,16 @@ git format-patch main --stdout | ssh pr.pico.sh pr create {{.ID}}</pre>
11   <h3 class="text-lg">Open PRs</h3>
12   {{range .OpenPrs}}
13     <div class="box">{{template "pr-list-item" .}}</div>
14+  {{else}}
15+    <div>No open patch requests.</div>
16+  {{end}}
17+
18+  {{if .ReviewedPrs}}
19+    <hr class="my w-full" />
20+    <h3 class="text-lg">Reviews PRs</h3>
21+    {{range .ReviewedPrs}}
22+      <div class="box">{{template "pr-list-item" .}}</div>
23+    {{end}}
24   {{end}}
25 
26   {{if .AcceptedPrs}}
M web.go
+8, -0
 1@@ -155,9 +155,11 @@ type PrListData struct {
 2 type RepoDetailData struct {
 3 	ID          string
 4 	CloneAddr   string
 5+	Branch      string
 6 	OpenPrs     []PrListData
 7 	AcceptedPrs []PrListData
 8 	ClosedPrs   []PrListData
 9+	ReviewedPrs []PrListData
10 }
11 
12 func repoDetailHandler(w http.ResponseWriter, r *http.Request) {
13@@ -185,6 +187,7 @@ func repoDetailHandler(w http.ResponseWriter, r *http.Request) {
14 	}
15 
16 	openList := []PrListData{}
17+	reviewedList := []PrListData{}
18 	acceptedList := []PrListData{}
19 	closedList := []PrListData{}
20 	for _, curpr := range prs {
21@@ -202,6 +205,8 @@ func repoDetailHandler(w http.ResponseWriter, r *http.Request) {
22 			openList = append(openList, ls)
23 		} else if curpr.Status == "accepted" {
24 			acceptedList = append(acceptedList, ls)
25+		} else if curpr.Status == "reviewed" {
26+			reviewedList = append(reviewedList, ls)
27 		} else {
28 			closedList = append(closedList, ls)
29 		}
30@@ -212,6 +217,7 @@ func repoDetailHandler(w http.ResponseWriter, r *http.Request) {
31 	err = tmpl.Execute(w, RepoDetailData{
32 		ID:          repo.ID,
33 		CloneAddr:   repo.CloneAddr,
34+		Branch:      repo.DefaultBranch,
35 		OpenPrs:     openList,
36 		AcceptedPrs: acceptedList,
37 		ClosedPrs:   closedList,
38@@ -240,6 +246,7 @@ type PrHeaderData struct {
39 	Repo    LinkData
40 	Pr      PrData
41 	Patches []PatchData
42+	Branch  string
43 }
44 
45 func prDetailHandler(w http.ResponseWriter, r *http.Request) {
46@@ -300,6 +307,7 @@ func prDetailHandler(w http.ResponseWriter, r *http.Request) {
47 			Url:  template.URL("/repos/" + repo.ID),
48 			Text: repo.ID,
49 		},
50+		Branch:  repo.DefaultBranch,
51 		Patches: patchesData,
52 		Pr: PrData{
53 			ID:     pr.ID,