Skip to content

Commit 1a2fafc

Browse files
committed
Handle archived packages in package info
1 parent db9b1a0 commit 1a2fafc

14 files changed

Lines changed: 403 additions & 39 deletions

src/dcf/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ pub struct Package {
366366
// `SHA256Original` in ALLPACKAGES, and its own rewritten tarball's hash
367367
// `SHA256`, which we do not keep.
368368
pub sha256sum: Option<String>,
369+
// the date CRAN archived the package, as `YYYY-MM-DD`. Only the
370+
// ARCHIVEDPACKAGES feed has this field, every other repo leaves it unset.
371+
pub archived: Option<String>,
369372
}
370373

371374
impl Package {
@@ -391,6 +394,7 @@ impl Package {
391394
internals_id: None,
392395
filesize: None,
393396
sha256sum: None,
397+
archived: None,
394398
}
395399
}
396400

@@ -421,6 +425,7 @@ impl Package {
421425
let internals_id = pkg.get("InternalsID").map(|i| i.to_string());
422426
let filesize = pkg.get("Filesize").and_then(|s| s.parse::<u64>().ok());
423427
let sha256sum = pkg.get("SHA256Original").map(|s| s.to_string());
428+
let archived = pkg.get("Archived").map(|a| a.to_string());
424429

425430
Ok(Package {
426431
name,
@@ -437,6 +442,7 @@ impl Package {
437442
internals_id,
438443
filesize,
439444
sha256sum,
445+
archived,
440446
})
441447
}
442448
}

src/help-generated.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ const HELP_REPOS_AVAILABLE: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{
4747
const ABOUT_REPOS_LIST: &str = "List configured R package repositories";
4848
const HELP_REPOS_LIST: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List the package repositories configured for an R version.\n\n By default rig shows the repositories of the default R version; use\n \u{1b}[32m--r-version\u{1b}[39m to pick another. Add \u{1b}[32m--all\u{1b}[39m to include repositories that\n are not enabled by default, and \u{1b}[32m--raw\u{1b}[39m to show repository URLs without\n resolving the \u{1b}[32m%\u{1b}[39m variables in them.";
4949
const ABOUT_REPOS_PACKAGE_INFO: &str = "Information about the package in the repositories";
50-
const HELP_REPOS_PACKAGE_INFO: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Show information about a package on CRAN, from its \u{1b}[32mDESCRIPTION\u{1b}[39m file.\n\n By default the latest available version is shown; use \u{1b}[32m--version\u{1b}[39m to\n select a specific one, including versions that CRAN has archived. Use\n \u{1b}[32m--json\u{1b}[39m to print all \u{1b}[32mDESCRIPTION\u{1b}[39m fields.\n\n The README of the package is shown as well, when the repository has one.\n Since this can be long, the output is paged through \u{1b}[32m$RIG_PAGER\u{1b}[39m,\n \u{1b}[32m$PAGER\u{1b}[39m, or \u{1b}[32mless\u{1b}[39m, unless it is redirected to a file or a pipe. Set\n \u{1b}[32mRIG_PAGER=cat\u{1b}[39m to turn paging off.\n\n Markdown READMEs are rendered for the terminal. GitHub emoji shortcodes\n like \u{1b}[32m:rocket:\u{1b}[39m become emoji, and links and images become clickable\n terminal hyperlinks on their link text, so a badge shows as its name\n instead of two long URLs. When the output is redirected, or \u{1b}[32mNO_COLOR\u{1b}[39m is\n set, the link target is written out as \u{1b}[32mtext (url)\u{1b}[39m instead. HTML\n comments and tags are dropped, an \u{1b}[32m<img>\u{1b}[39m leaving its \u{1b}[32malt\u{1b}[39m text behind,\n and paragraphs are rewrapped to the width of the output.";
50+
const HELP_REPOS_PACKAGE_INFO: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Show information about a package on CRAN, from its \u{1b}[32mDESCRIPTION\u{1b}[39m file.\n\n By default the latest available version is shown; use \u{1b}[32m--version\u{1b}[39m to\n select a specific one, including versions that CRAN has archived. Use\n \u{1b}[32m--json\u{1b}[39m to print all \u{1b}[32mDESCRIPTION\u{1b}[39m fields.\n\n If CRAN has archived the package, i.e. removed it from the current\n repository, rig shows the date it was archived, next to the publication\n date of the version. \u{1b}[32m--json\u{1b}[39m reports it as an extra \u{1b}[32mArchived\u{1b}[39m field.\n\n The README of the package is shown as well, when the repository has one.\n Since this can be long, the output is paged through \u{1b}[32m$RIG_PAGER\u{1b}[39m,\n \u{1b}[32m$PAGER\u{1b}[39m, or \u{1b}[32mless\u{1b}[39m, unless it is redirected to a file or a pipe. Set\n \u{1b}[32mRIG_PAGER=cat\u{1b}[39m to turn paging off.\n\n Markdown READMEs are rendered for the terminal. GitHub emoji shortcodes\n like \u{1b}[32m:rocket:\u{1b}[39m become emoji, and links and images become clickable\n terminal hyperlinks on their link text, so a badge shows as its name\n instead of two long URLs. When the output is redirected, or \u{1b}[32mNO_COLOR\u{1b}[39m is\n set, the link target is written out as \u{1b}[32mtext (url)\u{1b}[39m instead. HTML\n comments and tags are dropped, an \u{1b}[32m<img>\u{1b}[39m leaving its \u{1b}[32malt\u{1b}[39m text behind,\n and paragraphs are rewrapped to the width of the output.";
5151
const ABOUT_REPOS_PACKAGE_LIST: &str = "List packages in R package repositories";
5252
const HELP_REPOS_PACKAGE_LIST: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List the packages available from the configured package repositories,\n ordered by name. For each package rig shows its version and its number of\n hard dependencies (\u{1b}[32mDepends\u{1b}[39m, \u{1b}[32mImports\u{1b}[39m and \u{1b}[32mLinkingTo\u{1b}[39m, excluding R and\n the base packages). A header line reports the total number of packages and\n the R version and package type they were resolved for.\n\n By default rig uses the default R version and the current platform;\n override these with \u{1b}[32m--r-version\u{1b}[39m, \u{1b}[32m--platform\u{1b}[39m and \u{1b}[32m--pkg-type\u{1b}[39m (e.g.\n \u{1b}[32msource\u{1b}[39m or \u{1b}[32mbinary\u{1b}[39m).\n\n Use \u{1b}[32m--json\u{1b}[39m to print the full listing as JSON, including the complete\n dependency lists for every package. See\n \u{1b}[32mrig repos package-info\u{1b}[39m for a detailed view of\n a single package and \u{1b}[32mrig repos package-versions\u{1b}[39m\n to list all versions of a package.";
5353
const ABOUT_REPOS_PACKAGE_VERSIONS: &str = "List all versions of a package in the repositories";
54-
const HELP_REPOS_PACKAGE_VERSIONS: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List all versions of a package ever published on CRAN, oldest first. For\n each version rig shows its publication date, its R version requirement\n and its number of hard dependencies (\u{1b}[32mDepends\u{1b}[39m, \u{1b}[32mImports\u{1b}[39m and\n \u{1b}[32mLinkingTo\u{1b}[39m, excluding R and the base packages); the latest version is\n marked.\n\n Use \u{1b}[32m--json\u{1b}[39m to print the full \u{1b}[32mDESCRIPTION\u{1b}[39m of every version. See\n \u{1b}[32mrig repos package-info\u{1b}[39m for a detailed view\n of a single version.";
54+
const HELP_REPOS_PACKAGE_VERSIONS: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List all versions of a package ever published on CRAN, oldest first. For\n each version rig shows its publication date, its R version requirement\n and its number of hard dependencies (\u{1b}[32mDepends\u{1b}[39m, \u{1b}[32mImports\u{1b}[39m and\n \u{1b}[32mLinkingTo\u{1b}[39m, excluding R and the base packages); the latest version is\n marked.\n\n For a package CRAN has archived, i.e. removed from the current\n repository, the header also shows the date it was archived. This applies\n to the package as a whole, so all of its versions are archived.\n\n Use \u{1b}[32m--json\u{1b}[39m to print the full \u{1b}[32mDESCRIPTION\u{1b}[39m of every version, each with\n an extra \u{1b}[32mArchived\u{1b}[39m field for an archived package. See\n \u{1b}[32mrig repos package-info\u{1b}[39m for a detailed view\n of a single version.";
5555
const ABOUT_REPOS_SETUP: &str = "Set up R package repositories";
5656
const HELP_REPOS_SETUP: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Set up the package repositories for installed R versions.\n\n By default rig configures the repositories for all installed R versions;\n use \u{1b}[32m--r-version\u{1b}[39m to restrict it to one. Use \u{1b}[32m--with-repos\u{1b}[39m and\n \u{1b}[32m--without-repos\u{1b}[39m to control which repositories are enabled, the same way\n as for \u{1b}[32mrig add\u{1b}[39m.";
5757
const ABOUT_REPOS: &str = "Manage package repositories";

src/help/repos-package-info.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ By default the latest available version is shown; use `--version` to
88
select a specific one, including versions that CRAN has archived. Use
99
`--json` to print all `DESCRIPTION` fields.
1010

11+
If CRAN has archived the package, i.e. removed it from the current
12+
repository, rig shows the date it was archived, next to the publication
13+
date of the version. `--json` reports it as an extra `Archived` field.
14+
1115
The README of the package is shown as well, when the repository has one.
1216
Since this can be long, the output is paged through `$RIG_PAGER`,
1317
`$PAGER`, or `less`, unless it is redirected to a file or a pipe. Set

src/help/repos-package-versions.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and its number of hard dependencies (`Depends`, `Imports` and
88
`LinkingTo`, excluding R and the base packages); the latest version is
99
marked.
1010

11-
Use `--json` to print the full `DESCRIPTION` of every version. See
11+
For a package CRAN has archived, i.e. removed from the current
12+
repository, the header also shows the date it was archived. This applies
13+
to the package as a whole, so all of its versions are archived.
14+
15+
Use `--json` to print the full `DESCRIPTION` of every version, each with
16+
an extra `Archived` field for an archived package. See
1217
[`rig repos package-info`](#rig-repos-package-info) for a detailed view
1318
of a single version.

0 commit comments

Comments
 (0)