- commit
- 1da1c02
- parent
- d16de93
- author
- Eric Bower
- date
- 2024-06-27 19:14:37 -0400 EDT
fix: rss
M
cli.go
+26,
-7
1@@ -50,10 +50,14 @@ Here's how it works:
2 Writer: sesh,
3 ErrWriter: sesh,
4 ExitErrHandler: func(cCtx *cli.Context, err error) {
5- wish.Fatalln(sesh, err)
6+ if err != nil {
7+ wish.Fatalln(sesh, err)
8+ }
9 },
10 OnUsageError: func(cCtx *cli.Context, err error, isSubcommand bool) error {
11- wish.Fatalln(sesh, err)
12+ if err != nil {
13+ wish.Fatalln(sesh, err)
14+ }
15 return nil
16 },
17 Commands: []*cli.Command{
18@@ -229,16 +233,26 @@ Here's how it works:
19 }
20
21 repoID := cCtx.Args().First()
22- request, err := pr.SubmitPatchRequest(repoID, user.ID, sesh)
23+ prq, err := pr.SubmitPatchRequest(repoID, user.ID, sesh)
24 if err != nil {
25 return err
26 }
27- wish.Printf(
28+ wish.Println(
29 sesh,
30- "PR submitted! Use the ID for interacting with this PR.\nID\tName\n%d\t%s\n",
31- request.ID,
32- request.Name,
33+ "PR submitted! Use the ID for interacting with this PR.",
34 )
35+
36+ writer := NewTabWriter(sesh)
37+ fmt.Fprintln(writer, "ID\tName\tURL")
38+ fmt.Fprintf(
39+ writer,
40+ "%d\t%s\t%s\n",
41+ prq.ID,
42+ prq.Name,
43+ fmt.Sprintf("https://%s/prs/%d", be.Cfg.Url, prq.ID),
44+ )
45+ writer.Flush()
46+
47 return nil
48 },
49 },
50@@ -671,6 +685,11 @@ Here's how it works:
51 )
52 }
53 writer.Flush()
54+
55+ wish.Println(
56+ sesh,
57+ fmt.Sprintf("https://%s/prs/%d", be.Cfg.Url, prq.ID),
58+ )
59 return nil
60 },
61 },
M
db.go
+15,
-15
1@@ -43,21 +43,21 @@ type PatchRequest struct {
2 // Patch is a database model for a single entry in a patchset.
3 // This usually corresponds to a git commit.
4 type Patch struct {
5- ID int64 `db:"id"`
6- UserID int64 `db:"user_id"`
7- PatchRequestID int64 `db:"patch_request_id"`
8- AuthorName string `db:"author_name"`
9- AuthorEmail string `db:"author_email"`
10- AuthorDate string `db:"author_date"`
11- Title string `db:"title"`
12- Body string `db:"body"`
13- BodyAppendix string `db:"body_appendix"`
14- CommitSha string `db:"commit_sha"`
15- ContentSha string `db:"content_sha"`
16- BaseCommitSha string `db:"base_commit_sha"`
17- Review bool `db:"review"`
18- RawText string `db:"raw_text"`
19- CreatedAt time.Time `db:"created_at"`
20+ ID int64 `db:"id"`
21+ UserID int64 `db:"user_id"`
22+ PatchRequestID int64 `db:"patch_request_id"`
23+ AuthorName string `db:"author_name"`
24+ AuthorEmail string `db:"author_email"`
25+ AuthorDate string `db:"author_date"`
26+ Title string `db:"title"`
27+ Body string `db:"body"`
28+ BodyAppendix string `db:"body_appendix"`
29+ CommitSha string `db:"commit_sha"`
30+ ContentSha string `db:"content_sha"`
31+ BaseCommitSha sql.NullString `db:"base_commit_sha"`
32+ Review bool `db:"review"`
33+ RawText string `db:"raw_text"`
34+ CreatedAt time.Time `db:"created_at"`
35 }
36
37 // EventLog is a event log for RSS or other notification systems.
M
pr.go
+2,
-1
1@@ -2,6 +2,7 @@ package git
2
3 import (
4 "crypto/sha256"
5+ "database/sql"
6 "encoding/hex"
7 "errors"
8 "fmt"
9@@ -427,7 +428,7 @@ func (cmd PrCmd) parsePatchSet(patchset io.Reader) ([]*Patch, error) {
10 CommitSha: header.SHA,
11 ContentSha: contentSha,
12 RawText: patchRaw,
13- BaseCommitSha: baseCommit,
14+ BaseCommitSha: sql.NullString{String: baseCommit},
15 })
16 }
17
M
web.go
+6,
-5
1@@ -371,11 +371,7 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
2 id := r.PathValue("id")
3 repoID := r.PathValue("repoid")
4 pubkey := r.URL.Query().Get("pubkey")
5- user, err := web.Pr.GetUserByPubkey(pubkey)
6- if err != nil {
7- w.WriteHeader(http.StatusNotFound)
8- return
9- }
10+
11 if id != "" {
12 var prID int64
13 prID, err = getPrID(id)
14@@ -385,6 +381,11 @@ func rssHandler(w http.ResponseWriter, r *http.Request) {
15 }
16 eventLogs, err = web.Pr.GetEventLogsByPrID(prID)
17 } else if pubkey != "" {
18+ user, perr := web.Pr.GetUserByPubkey(pubkey)
19+ if perr != nil {
20+ w.WriteHeader(http.StatusNotFound)
21+ return
22+ }
23 eventLogs, err = web.Pr.GetEventLogsByUserID(user.ID)
24 } else if repoID != "" {
25 eventLogs, err = web.Pr.GetEventLogsByRepoID(repoID)