~sumner/pr-tracker

dfb3518c1cd37d3fdb819c06b079508842766fb5 — Sumner Evans 6 months ago c01d3aa
pr-info: add author to PR information display
4 files changed, 27 insertions(+), 0 deletions(-)

M src/github.rs
M src/main.rs
M src/pr_info.graphql
M templates/page.html
M src/github.rs => src/github.rs +7 -0
@@ 100,6 100,7 @@ pub enum PullRequestStatus {
pub struct PrInfo {
    pub branch: String,
    pub title: String,
    pub author: String,
    pub status: PullRequestStatus,
}



@@ 169,9 170,15 @@ impl<'a> GitHub<'a> {
            PullRequestStatus::Open
        };

        let author = match pr.author {
            Some(a) => a.login,
            None => String::new(),
        };

        Ok(PrInfo {
            branch: pr.base_ref_name,
            title: pr.title,
            author,
            status,
        })
    }

M src/main.rs => src/main.rs +2 -0
@@ 71,6 71,7 @@ struct PageTemplate {
    error: Option<String>,
    pr_number: Option<String>,
    pr_title: Option<String>,
    pr_author: Option<String>,
    closed: bool,
    tree: Option<Tree>,
    source_url: String,


@@ 116,6 117,7 @@ async fn track_pr(pr_number: Option<String>, status: &mut u16, page: &mut PageTe

    page.pr_number = Some(pr_number);
    page.pr_title = Some(pr_info.title);
    page.pr_author = Some(pr_info.author);

    if matches!(pr_info.status, PullRequestStatus::Closed) {
        page.closed = true;

M src/pr_info.graphql => src/pr_info.graphql +4 -0
@@ 5,6 5,10 @@ query PrInfoQuery($owner: String!, $repo: String!, $number: Int!) {
  repository(owner: $owner, name: $repo) {
    pullRequest(number: $number) {
      title
      author {
        __typename
        login
      }
      baseRefName
      mergeCommit {
        oid

M templates/page.html => templates/page.html +14 -0
@@ 82,6 82,10 @@
        margin: 0;
      }

      li > div table {
        line-height: 1.2em;
      }

      span {
        color: transparent;
        position: relative;


@@ 210,6 214,16 @@
                </tr>
                {%- else -%}
                {%- endmatch -%}
                {% match pr_author %}
                {%- when Some with (pr_author) -%}
                <tr>
                  <td><b>Author:</b></td>
                  <td>
                    <a href="https://github.com/{{ pr_author }}">{{ pr_author }}</a>
                  </td>
                </tr>
                {%- else -%}
                {%- endmatch -%}
              </table>
            </div>
          </div>