feat(dev): track pull request head revisions
This commit is contained in:
2 files changed
+9
-2
No files matched your search
@@ -32,6 +32,7 @@ type PR struct {
|
|||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
HeadRef string `json:"headRefName"`
|
HeadRef string `json:"headRefName"`
|
||||||
|
HeadSHA string `json:"headRefOid"`
|
||||||
CIState string `json:"ciState"`
|
CIState string `json:"ciState"`
|
||||||
IsDraft bool `json:"isDraft"`
|
IsDraft bool `json:"isDraft"`
|
||||||
UpdatedAt string `json:"updatedAt"`
|
UpdatedAt string `json:"updatedAt"`
|
||||||
@@ -45,6 +46,7 @@ type rawPR struct {
|
|||||||
Login string `json:"login"`
|
Login string `json:"login"`
|
||||||
} `json:"author"`
|
} `json:"author"`
|
||||||
HeadRefName string `json:"headRefName"`
|
HeadRefName string `json:"headRefName"`
|
||||||
|
HeadRefOID string `json:"headRefOid"`
|
||||||
UpdatedAt string `json:"updatedAt"`
|
UpdatedAt string `json:"updatedAt"`
|
||||||
StatusCheckRollup []rawCheck `json:"statusCheckRollup"`
|
StatusCheckRollup []rawCheck `json:"statusCheckRollup"`
|
||||||
}
|
}
|
||||||
@@ -108,7 +110,7 @@ func listPRs(ctx context.Context, limit int, includeBots, refresh bool) ([]PR, e
|
|||||||
"--repo", Repo,
|
"--repo", Repo,
|
||||||
"--state", "open",
|
"--state", "open",
|
||||||
"--limit", fmt.Sprint(limit),
|
"--limit", fmt.Sprint(limit),
|
||||||
"--json", "number,title,author,headRefName,updatedAt,isDraft,statusCheckRollup",
|
"--json", "number,title,author,headRefName,headRefOid,updatedAt,isDraft,statusCheckRollup",
|
||||||
).CombinedOutput()
|
).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = commandError(err, out)
|
err = commandError(err, out)
|
||||||
@@ -130,6 +132,7 @@ func listPRs(ctx context.Context, limit int, includeBots, refresh bool) ([]PR, e
|
|||||||
Title: r.Title,
|
Title: r.Title,
|
||||||
Author: r.Author.Login,
|
Author: r.Author.Login,
|
||||||
HeadRef: r.HeadRefName,
|
HeadRef: r.HeadRefName,
|
||||||
|
HeadSHA: r.HeadRefOID,
|
||||||
CIState: rollupState(r.StatusCheckRollup),
|
CIState: rollupState(r.StatusCheckRollup),
|
||||||
IsDraft: r.IsDraft,
|
IsDraft: r.IsDraft,
|
||||||
UpdatedAt: r.UpdatedAt,
|
UpdatedAt: r.UpdatedAt,
|
||||||
@@ -173,7 +176,7 @@ func commandError(err error, output []byte) error {
|
|||||||
func GetPR(ctx context.Context, number int) (*PR, error) {
|
func GetPR(ctx context.Context, number int) (*PR, error) {
|
||||||
out, err := exec.CommandContext(ctx, "gh", "pr", "view", fmt.Sprint(number),
|
out, err := exec.CommandContext(ctx, "gh", "pr", "view", fmt.Sprint(number),
|
||||||
"--repo", Repo,
|
"--repo", Repo,
|
||||||
"--json", "number,title,author,headRefName,updatedAt,isDraft,statusCheckRollup",
|
"--json", "number,title,author,headRefName,headRefOid,updatedAt,isDraft,statusCheckRollup",
|
||||||
).CombinedOutput()
|
).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, commandError(err, out)
|
return nil, commandError(err, out)
|
||||||
@@ -188,6 +191,7 @@ func GetPR(ctx context.Context, number int) (*PR, error) {
|
|||||||
Title: r.Title,
|
Title: r.Title,
|
||||||
Author: r.Author.Login,
|
Author: r.Author.Login,
|
||||||
HeadRef: r.HeadRefName,
|
HeadRef: r.HeadRefName,
|
||||||
|
HeadSHA: r.HeadRefOID,
|
||||||
CIState: rollupState(r.StatusCheckRollup),
|
CIState: rollupState(r.StatusCheckRollup),
|
||||||
IsDraft: r.IsDraft,
|
IsDraft: r.IsDraft,
|
||||||
UpdatedAt: r.UpdatedAt,
|
UpdatedAt: r.UpdatedAt,
|
||||||
|
|||||||
@@ -84,5 +84,8 @@ func TestListPRsExcludesBotsIntegration(t *testing.T) {
|
|||||||
if isBot(pr.Author) {
|
if isBot(pr.Author) {
|
||||||
t.Fatalf("bot PR was not filtered: #%d by %s", pr.Number, pr.Author)
|
t.Fatalf("bot PR was not filtered: #%d by %s", pr.Number, pr.Author)
|
||||||
}
|
}
|
||||||
|
if pr.HeadSHA == "" {
|
||||||
|
t.Fatalf("PR #%d has no head SHA", pr.Number)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user