repos / git-pr

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

commit
1824e58
parent
43c9d2e
author
Eric Bower
date
2024-07-12 20:39:17 -0400 EDT
chore(cli): desc order for ls commands
2 files changed,  +17, -12
M cli.go
M pr.go
M cli.go
+13, -8
 1@@ -170,6 +170,10 @@ Here's how it works:
 2 						Args:      true,
 3 						ArgsUsage: "[repoID]",
 4 						Flags: []cli.Flag{
 5+							&cli.BoolFlag{
 6+								Name:  "open",
 7+								Usage: "only show open PRs",
 8+							},
 9 							&cli.BoolFlag{
10 								Name:  "closed",
11 								Usage: "only show closed PRs",
12@@ -178,9 +182,9 @@ Here's how it works:
13 								Name:  "accepted",
14 								Usage: "only show accepted PRs",
15 							},
16-							&cli.StringFlag{
17-								Name:  "repo",
18-								Usage: "only show PRs by Repo ID",
19+							&cli.BoolFlag{
20+								Name:  "reviewed",
21+								Usage: "only show reviewed PRs",
22 							},
23 						},
24 						Action: func(cCtx *cli.Context) error {
25@@ -196,26 +200,27 @@ Here's how it works:
26 								return err
27 							}
28 
29+							onlyOpen := cCtx.Bool("open")
30 							onlyAccepted := cCtx.Bool("accepted")
31 							onlyClosed := cCtx.Bool("closed")
32-							onlyRepoID := cCtx.String("repo")
33+							onlyReviewed := cCtx.Bool("reviewed")
34 
35 							writer := NewTabWriter(sesh)
36 							fmt.Fprintln(writer, "ID\tRepoID\tName\tStatus\tUser\tDate")
37 							for _, req := range prs {
38-								if onlyRepoID != "" && req.RepoID != onlyRepoID {
39+								if onlyAccepted && req.Status != "accepted" {
40 									continue
41 								}
42 
43-								if onlyAccepted && req.Status != "accepted" {
44+								if onlyClosed && req.Status != "closed" {
45 									continue
46 								}
47 
48-								if onlyClosed && req.Status != "closed" {
49+								if onlyOpen && req.Status != "open" {
50 									continue
51 								}
52 
53-								if !onlyAccepted && !onlyClosed && req.Status != "open" {
54+								if onlyReviewed && req.Status != "reviewed" {
55 									continue
56 								}
57 
M pr.go
+4, -4
 1@@ -225,7 +225,7 @@ func (pr PrCmd) GetPatchesByPrID(prID int64) ([]*Patch, error) {
 2 	patches := []*Patch{}
 3 	err := pr.Backend.DB.Select(
 4 		&patches,
 5-		"SELECT * FROM patches WHERE patch_request_id=?",
 6+		"SELECT * FROM patches WHERE patch_request_id=? ORDER BY created_at ASC, id ASC",
 7 		prID,
 8 	)
 9 	if err != nil {
10@@ -241,7 +241,7 @@ func (cmd PrCmd) GetPatchRequests() ([]*PatchRequest, error) {
11 	prs := []*PatchRequest{}
12 	err := cmd.Backend.DB.Select(
13 		&prs,
14-		"SELECT * FROM patch_requests",
15+		"SELECT * FROM patch_requests ORDER BY created_at DESC",
16 	)
17 	return prs, err
18 }
19@@ -250,7 +250,7 @@ func (cmd PrCmd) GetPatchRequestsByRepoID(repoID string) ([]*PatchRequest, error
20 	prs := []*PatchRequest{}
21 	err := cmd.Backend.DB.Select(
22 		&prs,
23-		"SELECT * FROM patch_requests WHERE repo_id=?",
24+		"SELECT * FROM patch_requests WHERE repo_id=? ORDER BY created_at DESC",
25 		repoID,
26 	)
27 	return prs, err
28@@ -260,7 +260,7 @@ func (cmd PrCmd) GetPatchRequestByID(prID int64) (*PatchRequest, error) {
29 	pr := PatchRequest{}
30 	err := cmd.Backend.DB.Get(
31 		&pr,
32-		"SELECT * FROM patch_requests WHERE id=?",
33+		"SELECT * FROM patch_requests WHERE id=? ORDER BY created_at DESC",
34 		prID,
35 	)
36 	return &pr, err