r-lib / desc
Showing 1 of 7 files from the diff.

@@ -263,7 +263,7 @@
Loading
263 263
  } else {
264 264
    au <- if (length(wh$index) == 1) "Author" else "Authors"
265 265
    desc_message(
266 -
      au, "removed: ",
266 +
      au, " removed: ",
267 267
      paste(wh$authors$given, wh$authors$family, collapse = ", "),
268 268
      "."
269 269
    )
@@ -373,45 +373,64 @@
Loading
373 373
  }
374 374
}
375 375
376 -
377 376
idesc_coerce_authors_at_r <- function(self, private) {
378 -
  has_authors_at_r = self$has_fields("Authors@R")
379 -
  has_author = self$has_fields("Author")
380 -
  if (! (has_authors_at_r | has_author) ) {
377 +
378 +
  if (self$has_fields("Authors@R")) return(invisible(NULL)) # exit early
379 +
380 +
  if (!self$has_fields("Author")) {
381 +
381 382
    stop("No 'Authors@R' or 'Author' field!\n",
382 383
         "You can create one with $add_author")
383 -
  }
384 384
385 -
  if ( !has_authors_at_r & has_author) {
386 -
    # Get author field
387 -
    auth = self$get("Author")
388 -
    auth = as.person(auth)
389 -
    auth$role = "aut"
390 -
391 -
    # Get maintainer field - set creator role
392 -
    man = self$get_maintainer()
393 -
    man = as.person(man)
394 -
    man$role = c("cre")
395 -
396 -
    # Set author as maintainer
397 -
    auths = man
398 -
399 -
    # If Maintainer in Author field, remove it and keep the maintainer one
400 -
    # may want to use del_author
401 -
    check_same = function(x) {
402 -
      identical(c(man$given, man$family),
403 -
                c(x$given, x$family))
385 +
  } else {
386 +
387 +
    # helper function to set role if role is NULL
388 +
    set_role_if_null <- function(person, role) {
389 +
      if (length(person) == 1) {
390 +
        person$role <- person$role %||% role
391 +
      } else {
392 +
        person$role <- lapply(person$role, function(y) y %||% role)
393 +
      }
394 +
      person
404 395
    }
405 -
    same_auth = sapply(auth, check_same)
406 -
    auth = auth[!same_auth]
407 -
    if (length(auth) > 0) {
408 -
      auths = c(auths, auth)
396 +
397 +
    # Parse maintainer field as person and set role
398 +
    man <- self$get_maintainer()
399 +
    man <- as.person(man)
400 +
    man <- set_role_if_null(man, "cre")
401 +
402 +
    # Parse author field as person and set role
403 +
    auth <- self$get("Author")
404 +
    author_file <- grepl("AUTHOR", auth, ignore.case = FALSE, fixed = TRUE)
405 +
    if (author_file) {
406 +
      desc_message(
407 +
        "The 'Author' field seems to refer to an AUTHOR file we do not parse. \n",
408 +
        "Only the 'Maintainer' field will be converted to 'Authors@R'. \n",
409 +
        "You can add additional authors with $add_author."
410 +
      )
411 +
      auth <- man
412 +
      auth$role <- "aut"
413 +
    } else {
414 +
    auth <- as.person(auth)
415 +
    auth <- set_role_if_null(auth, "aut")
409 416
    }
417 +
418 +
    # Determine which author is the maintainer and split auth accordingly
419 +
    auth_in_man <- paste(auth$given, auth$family) %in% paste(man$given, man$family)
420 +
    mauth <- if(any(auth_in_man)) auth[auth_in_man] else man
421 +
    other_auth <- auth[!auth_in_man] # this is an empty list if single author
422 +
423 +
    # combine info from mauth and man
424 +
    mauth$role <- list(unique(c(mauth$role, man$role)))
425 +
    mauth$email <- man$email # email is mandatory for maintainers
426 +
    mauth$comment <- list(mauth$comment %||% man$comment)
427 +
428 +
    # combine all authors and set as authors@R
429 +
    auths = c(mauth, other_auth)
410 430
    self$set_authors(auths)
411 431
  }
412 432
}
413 433
414 -
415 434
# helper to add or replace ORCID in comment
416 435
add_orcid_to_comment <- function(comment, orcid){
417 436
Files Coverage
R 97.47%
Project Totals (18 files) 97.47%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading