From 868bccc51ecf502ffc3b981c30174489016f0431 Mon Sep 17 00:00:00 2001 From: jenna-a2ai Date: Mon, 23 Dec 2024 22:22:26 +0000 Subject: [PATCH] bug fix for branches --- R/app_02_resolve.R | 5 +++++ R/app_02_resolve_server.R | 3 +++ R/format_commit_shas.R | 5 +++-- R/qc_fix.R | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/R/app_02_resolve.R b/R/app_02_resolve.R index 2a54d2c..dcf29ca 100644 --- a/R/app_02_resolve.R +++ b/R/app_02_resolve.R @@ -32,6 +32,11 @@ ghqc_resolve_app <- function() { rlang::abort("There were no open Milestones found.") } + # fetch for other branches that might not be present locally + #suppressMessages(suppressWarnings(gert::git_fetch())) + # invisible(capture.output(gert::git_fetch())) + gert::git_fetch() + app <- shinyApp( ui = ghqc_resolve_ui( id = "ghqc_resolve_app" diff --git a/R/app_02_resolve_server.R b/R/app_02_resolve_server.R index 134752e..824f4cc 100644 --- a/R/app_02_resolve_server.R +++ b/R/app_02_resolve_server.R @@ -68,8 +68,11 @@ ghqc_resolve_server <- function(id, remote, org, repo, milestone_list) { all_commits <- reactive({ req(org, repo, issue_parts()$issue_number) + + get_commits_df( issue_number = issue_parts()$issue_number, + file_path = issue_parts()$issue_title, owner = org, repo = repo ) diff --git a/R/format_commit_shas.R b/R/format_commit_shas.R index 0d6020b..be47fd9 100644 --- a/R/format_commit_shas.R +++ b/R/format_commit_shas.R @@ -7,10 +7,11 @@ # add "second most recent commit", "most recent commit" and "original qc commit" identifiers # format in table -get_commits_df <- function(issue_number, owner = get_organization(), repo = get_current_repo()) { +get_commits_df <- function(issue_number, file_path, owner = get_organization(), repo = get_current_repo()) { init_qc_commit <- get_init_qc_commit(owner, repo, issue_number) + branch <- get_branch_from_metadata(owner, repo, issue_number) - all_commits <- gert::git_log() + all_commits <- gert::git_log(ref = paste0("origin/", branch)) cutoff_position <- which(all_commits$commit == init_qc_commit) diff --git a/R/qc_fix.R b/R/qc_fix.R index a1392bf..a9e1d97 100644 --- a/R/qc_fix.R +++ b/R/qc_fix.R @@ -10,6 +10,14 @@ get_init_qc_commit <- function(owner, repo, issue_number) { return(init_commit) } +get_branch_from_metadata <- function(owner, repo, issue_number) { + issue <- get_issue(owner, repo, issue_number) + text <- get_metadata(issue$body)$`git branch` + branch <- stringr::str_match(text, "\\[(.*?)\\]")[, 2] + + return(branch) +} + create_assignees_list <- function(assignees) { sapply(assignees, function(assignee) glue::glue("@{assignee$login}")) }