Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API to fetch repositories and list their branches. #12

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code review
  • Loading branch information
plietar committed Jan 13, 2025
commit 9353f30baee197f1f1f5bea04c4a7fdfbc755cee
19 changes: 10 additions & 9 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
##'
##' @param root Orderly root
##'
##' @param repositories Path in which Git repositories are cloned
##' @param repositories_base_path Path in which Git repositories are
##' cloned.
##'
##' @param validate Logical, indicating if validation should be done
##' on responses. This should be `FALSE` in production
Expand All @@ -21,7 +22,7 @@
##'
##' @export
api <- function(
root, repositories,
root, repositories_base_path,
validate = NULL, log_level = "info",
skip_queue_creation = FALSE) {
logger <- porcelain::porcelain_logger(log_level)
Expand All @@ -36,7 +37,7 @@ api <- function(
api <- porcelain::porcelain$new(validate = validate, logger = logger)
api$include_package_endpoints(state = list(
root = root,
repositories = repositories,
repositories_base_path = repositories_base_path,
queue = queue))
api
}
Expand All @@ -53,21 +54,21 @@ root <- function() {


##' @porcelain POST /repository/fetch => json(repository_fetch_response)
##' state repositories :: repositories
##' state repositories_base_path :: repositories_base_path
##' body data :: json(repository_fetch_request)
repository_fetch <- function(repositories, data) {
repository_fetch <- function(repositories_base_path, data) {
data <- jsonlite::parse_json(data)
r <- git_sync(repositories, data$url)
r <- git_sync(repositories_base_path, data$url)

empty_object()
}


##' @porcelain GET /repository/branches => json(repository_branches)
##' state repositories :: repositories
##' state repositories_base_path :: repositories_base_path
##' query url :: string
repository_branches <- function(repositories, url) {
repo <- repository_path(repositories, url)
repository_branches <- function(repositories_base_path, url) {
repo <- repository_path(repositories_base_path, url)
branches <- git_remote_list_branches(repo)
message <- vcapply(branches$commit, function(commit) {
gert::git_commit_info(repo = repo, ref = commit)$message
Expand Down
4 changes: 2 additions & 2 deletions R/porcelain.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/api.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/helper-orderly-runner.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ orderly_runner_endpoint <- function(
porcelain::porcelain_package_endpoint(
"orderly.runner", method, path,
state = list(root = root,
repositories = repositories,
repositories_base_path = repositories,
queue = queue),
validate = validate
)
Expand Down
Loading