summaryrefslogtreecommitdiffstats
path: root/testing/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-30 16:53:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-30 16:53:19 +0000
commit02d5100afa71d1343de4066b812cd4cdc774d812 (patch)
tree6bccae957398fab29aaa226fb0bd65f0c258a36a /testing/resources
parentAdding upstream version 2.21.0. (diff)
downloadpre-commit-02d5100afa71d1343de4066b812cd4cdc774d812.tar.xz
pre-commit-02d5100afa71d1343de4066b812cd4cdc774d812.zip
Adding upstream version 3.0.2.upstream/3.0.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml10
-rw-r--r--testing/resources/conda_hooks_repo/environment.yml6
-rw-r--r--testing/resources/coursier_hooks_repo/.pre-commit-channel/echo-java.json8
-rw-r--r--testing/resources/coursier_hooks_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/dart_repo/.pre-commit-hooks.yaml4
-rw-r--r--testing/resources/dart_repo/bin/hello-world-dart.dart6
-rw-r--r--testing/resources/dart_repo/pubspec.yaml10
-rw-r--r--testing/resources/golang_hooks_repo/golang-hello-world/main.go8
-rw-r--r--testing/resources/lua_repo/.pre-commit-hooks.yaml4
-rwxr-xr-xtesting/resources/lua_repo/bin/hello-world-lua3
-rw-r--r--testing/resources/lua_repo/hello-dev-1.rockspec15
-rw-r--r--testing/resources/perl_hooks_repo/.gitignore7
-rw-r--r--testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml5
-rw-r--r--testing/resources/perl_hooks_repo/MANIFEST4
-rw-r--r--testing/resources/perl_hooks_repo/Makefile.PL10
-rwxr-xr-xtesting/resources/perl_hooks_repo/bin/pre-commit-perl-hello7
-rw-r--r--testing/resources/perl_hooks_repo/lib/PreCommitHello.pm12
-rw-r--r--testing/resources/r_hooks_repo/.pre-commit-hooks.yaml48
-rw-r--r--testing/resources/r_hooks_repo/DESCRIPTION19
-rwxr-xr-xtesting/resources/r_hooks_repo/additional-deps.R2
-rwxr-xr-xtesting/resources/r_hooks_repo/hello-world.R5
-rw-r--r--testing/resources/r_hooks_repo/renv.lock27
-rw-r--r--testing/resources/r_hooks_repo/renv/LICENSE7
-rw-r--r--testing/resources/r_hooks_repo/renv/activate.R440
-rw-r--r--testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml2
-rw-r--r--testing/resources/swift_hooks_repo/.gitignore4
-rw-r--r--testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml6
-rw-r--r--testing/resources/swift_hooks_repo/Package.swift7
-rw-r--r--testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift1
29 files changed, 8 insertions, 684 deletions
diff --git a/testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index a0d274c..0000000
--- a/testing/resources/conda_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-- id: sys-exec
- name: sys-exec
- entry: python -c 'import os; import sys; print(sys.executable.split(os.path.sep)[-2]) if os.name == "nt" else print(sys.executable.split(os.path.sep)[-3])'
- language: conda
- files: \.py$
-- id: additional-deps
- name: additional-deps
- entry: python
- language: conda
- files: \.py$
diff --git a/testing/resources/conda_hooks_repo/environment.yml b/testing/resources/conda_hooks_repo/environment.yml
deleted file mode 100644
index e23c079..0000000
--- a/testing/resources/conda_hooks_repo/environment.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-channels:
- - conda-forge
- - defaults
-dependencies:
- - python
- - pip
diff --git a/testing/resources/coursier_hooks_repo/.pre-commit-channel/echo-java.json b/testing/resources/coursier_hooks_repo/.pre-commit-channel/echo-java.json
deleted file mode 100644
index 37f401e..0000000
--- a/testing/resources/coursier_hooks_repo/.pre-commit-channel/echo-java.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "repositories": [
- "central"
- ],
- "dependencies": [
- "io.get-coursier:echo:latest.stable"
- ]
-}
diff --git a/testing/resources/coursier_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/coursier_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index d4a143b..0000000
--- a/testing/resources/coursier_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-- id: echo-java
- name: echo-java
- description: echo from java
- entry: echo-java
- language: coursier
diff --git a/testing/resources/dart_repo/.pre-commit-hooks.yaml b/testing/resources/dart_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index e0dc5a2..0000000
--- a/testing/resources/dart_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-- id: hello-world-dart
- name: hello world dart
- entry: hello-world-dart
- language: dart
diff --git a/testing/resources/dart_repo/bin/hello-world-dart.dart b/testing/resources/dart_repo/bin/hello-world-dart.dart
deleted file mode 100644
index 5d8d6a6..0000000
--- a/testing/resources/dart_repo/bin/hello-world-dart.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-import 'package:ansicolor/ansicolor.dart';
-
-void main() {
- AnsiPen pen = new AnsiPen()..red();
- print("hello hello " + pen("world"));
-}
diff --git a/testing/resources/dart_repo/pubspec.yaml b/testing/resources/dart_repo/pubspec.yaml
deleted file mode 100644
index bc719d0..0000000
--- a/testing/resources/dart_repo/pubspec.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-environment:
- sdk: '>=2.10.0 <3.0.0'
-
-name: hello_world_dart
-
-executables:
- hello-world-dart:
-
-dependencies:
- ansicolor: ^2.0.1
diff --git a/testing/resources/golang_hooks_repo/golang-hello-world/main.go b/testing/resources/golang_hooks_repo/golang-hello-world/main.go
index 1e3c591..1685743 100644
--- a/testing/resources/golang_hooks_repo/golang-hello-world/main.go
+++ b/testing/resources/golang_hooks_repo/golang-hello-world/main.go
@@ -3,7 +3,9 @@ package main
import (
"fmt"
+ "runtime"
"github.com/BurntSushi/toml"
+ "os"
)
type Config struct {
@@ -11,7 +13,11 @@ type Config struct {
}
func main() {
+ message := runtime.Version()
+ if len(os.Args) > 1 {
+ message = os.Args[1]
+ }
var conf Config
toml.Decode("What = 'world'\n", &conf)
- fmt.Printf("hello %v\n", conf.What)
+ fmt.Printf("hello %v from %s\n", conf.What, message)
}
diff --git a/testing/resources/lua_repo/.pre-commit-hooks.yaml b/testing/resources/lua_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index 767ef97..0000000
--- a/testing/resources/lua_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-- id: hello-world-lua
- name: hello world lua
- entry: hello-world-lua
- language: lua
diff --git a/testing/resources/lua_repo/bin/hello-world-lua b/testing/resources/lua_repo/bin/hello-world-lua
deleted file mode 100755
index 2a0e002..0000000
--- a/testing/resources/lua_repo/bin/hello-world-lua
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env lua
-
-print('hello world')
diff --git a/testing/resources/lua_repo/hello-dev-1.rockspec b/testing/resources/lua_repo/hello-dev-1.rockspec
deleted file mode 100644
index 82486e0..0000000
--- a/testing/resources/lua_repo/hello-dev-1.rockspec
+++ /dev/null
@@ -1,15 +0,0 @@
-package = "hello"
-version = "dev-1"
-
-source = {
- url = "git+ssh://git@github.com/pre-commit/pre-commit.git"
-}
-description = {}
-dependencies = {}
-build = {
- type = "builtin",
- modules = {},
- install = {
- bin = {"bin/hello-world-lua"}
- },
-}
diff --git a/testing/resources/perl_hooks_repo/.gitignore b/testing/resources/perl_hooks_repo/.gitignore
deleted file mode 100644
index 7af9940..0000000
--- a/testing/resources/perl_hooks_repo/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-/MYMETA.json
-/MYMETA.yml
-/Makefile
-/PreCommitHello-*.tar.*
-/PreCommitHello-*/
-/blib/
-/pm_to_blib
diff --git a/testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index 11e6f6c..0000000
--- a/testing/resources/perl_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-- id: perl-hook
- name: perl example hook
- entry: pre-commit-perl-hello
- language: perl
- files: ''
diff --git a/testing/resources/perl_hooks_repo/MANIFEST b/testing/resources/perl_hooks_repo/MANIFEST
deleted file mode 100644
index 4a20084..0000000
--- a/testing/resources/perl_hooks_repo/MANIFEST
+++ /dev/null
@@ -1,4 +0,0 @@
-MANIFEST
-Makefile.PL
-bin/pre-commit-perl-hello
-lib/PreCommitHello.pm
diff --git a/testing/resources/perl_hooks_repo/Makefile.PL b/testing/resources/perl_hooks_repo/Makefile.PL
deleted file mode 100644
index 6c70e10..0000000
--- a/testing/resources/perl_hooks_repo/Makefile.PL
+++ /dev/null
@@ -1,10 +0,0 @@
-use strict;
-use warnings;
-
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => "PreCommitHello",
- VERSION_FROM => "lib/PreCommitHello.pm",
- EXE_FILES => [qw(bin/pre-commit-perl-hello)],
-);
diff --git a/testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello b/testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello
deleted file mode 100755
index 9474009..0000000
--- a/testing/resources/perl_hooks_repo/bin/pre-commit-perl-hello
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-use PreCommitHello;
-
-PreCommitHello::hello();
diff --git a/testing/resources/perl_hooks_repo/lib/PreCommitHello.pm b/testing/resources/perl_hooks_repo/lib/PreCommitHello.pm
deleted file mode 100644
index c76521c..0000000
--- a/testing/resources/perl_hooks_repo/lib/PreCommitHello.pm
+++ /dev/null
@@ -1,12 +0,0 @@
-package PreCommitHello;
-
-use strict;
-use warnings;
-
-our $VERSION = "0.1.0";
-
-sub hello {
- print "Hello from perl-commit Perl!\n";
-}
-
-1;
diff --git a/testing/resources/r_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/r_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index b3545d9..0000000
--- a/testing/resources/r_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-# parsing file
-- id: parse-file-no-opts-no-args
- name: Say hi
- entry: Rscript parse-file-no-opts-no-args.R
- language: r
- types: [r]
-- id: parse-file-no-opts-args
- name: Say hi
- entry: Rscript parse-file-no-opts-args.R
- args: [--no-cache]
- language: r
- types: [r]
-## parsing expr
-- id: parse-expr-no-opts-no-args-1
- name: Say hi
- entry: Rscript -e '1+1'
- language: r
- types: [r]
-- id: parse-expr-args-in-entry-2
- name: Say hi
- entry: Rscript -e '1+1' -e '3' --no-cache3
- language: r
- types: [r]
-# real world
-- id: hello-world
- name: Say hi
- entry: Rscript hello-world.R
- args: [blibla]
- language: r
- types: [r]
-- id: hello-world-inline
- name: Say hi
- entry: |
- Rscript -e
- 'stopifnot(
- packageVersion("rprojroot") == "1.0",
- packageVersion("gli.clu") == "0.0.0.9000"
- )
- cat(commandArgs(trailingOnly = TRUE), "from R!\n", sep = ", ")
- '
- args: ['Hi-there']
- language: r
- types: [r]
-- id: additional-deps
- name: Check additional deps
- entry: Rscript additional-deps.R
- language: r
- types: [r]
diff --git a/testing/resources/r_hooks_repo/DESCRIPTION b/testing/resources/r_hooks_repo/DESCRIPTION
deleted file mode 100644
index 0e597a8..0000000
--- a/testing/resources/r_hooks_repo/DESCRIPTION
+++ /dev/null
@@ -1,19 +0,0 @@
-Package: gli.clu
-Title: What the Package Does (One Line, Title Case)
-Type: Package
-Version: 0.0.0.9000
-Authors@R:
- person(given = "First",
- family = "Last",
- role = c("aut", "cre"),
- email = "first.last@example.com",
- comment = c(ORCID = "YOUR-ORCID-ID"))
-Description: What the package does (one paragraph).
-License: `use_mit_license()`, `use_gpl3_license()` or friends to
- pick a license
-Encoding: UTF-8
-LazyData: true
-Roxygen: list(markdown = TRUE)
-RoxygenNote: 7.1.1
-Imports:
- rprojroot
diff --git a/testing/resources/r_hooks_repo/additional-deps.R b/testing/resources/r_hooks_repo/additional-deps.R
deleted file mode 100755
index bc14595..0000000
--- a/testing/resources/r_hooks_repo/additional-deps.R
+++ /dev/null
@@ -1,2 +0,0 @@
-suppressPackageStartupMessages(library("cachem"))
-cat("OK\n")
diff --git a/testing/resources/r_hooks_repo/hello-world.R b/testing/resources/r_hooks_repo/hello-world.R
deleted file mode 100755
index bf8d92f..0000000
--- a/testing/resources/r_hooks_repo/hello-world.R
+++ /dev/null
@@ -1,5 +0,0 @@
-stopifnot(
- packageVersion('rprojroot') == '1.0',
- packageVersion('gli.clu') == '0.0.0.9000'
-)
-cat("Hello, World, from R!\n")
diff --git a/testing/resources/r_hooks_repo/renv.lock b/testing/resources/r_hooks_repo/renv.lock
deleted file mode 100644
index d7d5fdc..0000000
--- a/testing/resources/r_hooks_repo/renv.lock
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "R": {
- "Version": "4.0.3",
- "Repositories": [
- {
- "Name": "CRAN",
- "URL": "https://cloud.r-project.org"
- }
- ]
- },
- "Packages": {
- "renv": {
- "Package": "renv",
- "Version": "0.12.5",
- "Source": "Repository",
- "Repository": "CRAN",
- "Hash": "5c0cdb37f063c58cdab3c7e9fbb8bd2c"
- },
- "rprojroot": {
- "Package": "rprojroot",
- "Version": "1.0",
- "Source": "Repository",
- "Repository": "CRAN",
- "Hash": "86704667fe0860e4fec35afdfec137f3"
- }
- }
-}
diff --git a/testing/resources/r_hooks_repo/renv/LICENSE b/testing/resources/r_hooks_repo/renv/LICENSE
deleted file mode 100644
index 253c5d1..0000000
--- a/testing/resources/r_hooks_repo/renv/LICENSE
+++ /dev/null
@@ -1,7 +0,0 @@
-Copyright 2021 RStudio, PBC
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/testing/resources/r_hooks_repo/renv/activate.R b/testing/resources/r_hooks_repo/renv/activate.R
deleted file mode 100644
index d8d092c..0000000
--- a/testing/resources/r_hooks_repo/renv/activate.R
+++ /dev/null
@@ -1,440 +0,0 @@
-
-local({
-
- # the requested version of renv
- version <- "0.12.5"
-
- # the project directory
- project <- getwd()
-
- # avoid recursion
- if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA)))
- return(invisible(TRUE))
-
- # signal that we're loading renv during R startup
- Sys.setenv("RENV_R_INITIALIZING" = "true")
- on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE)
-
- # signal that we've consented to use renv
- options(renv.consent = TRUE)
-
- # load the 'utils' package eagerly -- this ensures that renv shims, which
- # mask 'utils' packages, will come first on the search path
- library(utils, lib.loc = .Library)
-
- # check to see if renv has already been loaded
- if ("renv" %in% loadedNamespaces()) {
-
- # if renv has already been loaded, and it's the requested version of renv,
- # nothing to do
- spec <- .getNamespaceInfo(.getNamespace("renv"), "spec")
- if (identical(spec[["version"]], version))
- return(invisible(TRUE))
-
- # otherwise, unload and attempt to load the correct version of renv
- unloadNamespace("renv")
-
- }
-
- # load bootstrap tools
- bootstrap <- function(version, library) {
-
- # attempt to download renv
- tarball <- tryCatch(renv_bootstrap_download(version), error = identity)
- if (inherits(tarball, "error"))
- stop("failed to download renv ", version)
-
- # now attempt to install
- status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity)
- if (inherits(status, "error"))
- stop("failed to install renv ", version)
-
- }
-
- renv_bootstrap_tests_running <- function() {
- getOption("renv.tests.running", default = FALSE)
- }
-
- renv_bootstrap_repos <- function() {
-
- # check for repos override
- repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA)
- if (!is.na(repos))
- return(repos)
-
- # if we're testing, re-use the test repositories
- if (renv_bootstrap_tests_running())
- return(getOption("renv.tests.repos"))
-
- # retrieve current repos
- repos <- getOption("repos")
-
- # ensure @CRAN@ entries are resolved
- repos[repos == "@CRAN@"] <- "https://cloud.r-project.org"
-
- # add in renv.bootstrap.repos if set
- default <- c(CRAN = "https://cloud.r-project.org")
- extra <- getOption("renv.bootstrap.repos", default = default)
- repos <- c(repos, extra)
-
- # remove duplicates that might've snuck in
- dupes <- duplicated(repos) | duplicated(names(repos))
- repos[!dupes]
-
- }
-
- renv_bootstrap_download <- function(version) {
-
- # if the renv version number has 4 components, assume it must
- # be retrieved via github
- nv <- numeric_version(version)
- components <- unclass(nv)[[1]]
-
- methods <- if (length(components) == 4L) {
- list(
- renv_bootstrap_download_github
- )
- } else {
- list(
- renv_bootstrap_download_cran_latest,
- renv_bootstrap_download_cran_archive
- )
- }
-
- for (method in methods) {
- path <- tryCatch(method(version), error = identity)
- if (is.character(path) && file.exists(path))
- return(path)
- }
-
- stop("failed to download renv ", version)
-
- }
-
- renv_bootstrap_download_impl <- function(url, destfile) {
-
- mode <- "wb"
-
- # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715
- fixup <-
- Sys.info()[["sysname"]] == "Windows" &&
- substring(url, 1L, 5L) == "file:"
-
- if (fixup)
- mode <- "w+b"
-
- utils::download.file(
- url = url,
- destfile = destfile,
- mode = mode,
- quiet = TRUE
- )
-
- }
-
- renv_bootstrap_download_cran_latest <- function(version) {
-
- repos <- renv_bootstrap_download_cran_latest_find(version)
-
- message("* Downloading renv ", version, " from CRAN ... ", appendLF = FALSE)
-
- info <- tryCatch(
- utils::download.packages(
- pkgs = "renv",
- repos = repos,
- destdir = tempdir(),
- quiet = TRUE
- ),
- condition = identity
- )
-
- if (inherits(info, "condition")) {
- message("FAILED")
- return(FALSE)
- }
-
- message("OK")
- info[1, 2]
-
- }
-
- renv_bootstrap_download_cran_latest_find <- function(version) {
-
- all <- renv_bootstrap_repos()
-
- for (repos in all) {
-
- db <- tryCatch(
- as.data.frame(
- x = utils::available.packages(repos = repos),
- stringsAsFactors = FALSE
- ),
- error = identity
- )
-
- if (inherits(db, "error"))
- next
-
- entry <- db[db$Package %in% "renv" & db$Version %in% version, ]
- if (nrow(entry) == 0)
- next
-
- return(repos)
-
- }
-
- fmt <- "renv %s is not available from your declared package repositories"
- stop(sprintf(fmt, version))
-
- }
-
- renv_bootstrap_download_cran_archive <- function(version) {
-
- name <- sprintf("renv_%s.tar.gz", version)
- repos <- renv_bootstrap_repos()
- urls <- file.path(repos, "src/contrib/Archive/renv", name)
- destfile <- file.path(tempdir(), name)
-
- message("* Downloading renv ", version, " from CRAN archive ... ", appendLF = FALSE)
-
- for (url in urls) {
-
- status <- tryCatch(
- renv_bootstrap_download_impl(url, destfile),
- condition = identity
- )
-
- if (identical(status, 0L)) {
- message("OK")
- return(destfile)
- }
-
- }
-
- message("FAILED")
- return(FALSE)
-
- }
-
- renv_bootstrap_download_github <- function(version) {
-
- enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE")
- if (!identical(enabled, "TRUE"))
- return(FALSE)
-
- # prepare download options
- pat <- Sys.getenv("GITHUB_PAT")
- if (nzchar(Sys.which("curl")) && nzchar(pat)) {
- fmt <- "--location --fail --header \"Authorization: token %s\""
- extra <- sprintf(fmt, pat)
- saved <- options("download.file.method", "download.file.extra")
- options(download.file.method = "curl", download.file.extra = extra)
- on.exit(do.call(base::options, saved), add = TRUE)
- } else if (nzchar(Sys.which("wget")) && nzchar(pat)) {
- fmt <- "--header=\"Authorization: token %s\""
- extra <- sprintf(fmt, pat)
- saved <- options("download.file.method", "download.file.extra")
- options(download.file.method = "wget", download.file.extra = extra)
- on.exit(do.call(base::options, saved), add = TRUE)
- }
-
- message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE)
-
- url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version)
- name <- sprintf("renv_%s.tar.gz", version)
- destfile <- file.path(tempdir(), name)
-
- status <- tryCatch(
- renv_bootstrap_download_impl(url, destfile),
- condition = identity
- )
-
- if (!identical(status, 0L)) {
- message("FAILED")
- return(FALSE)
- }
-
- message("OK")
- return(destfile)
-
- }
-
- renv_bootstrap_install <- function(version, tarball, library) {
-
- # attempt to install it into project library
- message("* Installing renv ", version, " ... ", appendLF = FALSE)
- dir.create(library, showWarnings = FALSE, recursive = TRUE)
-
- # invoke using system2 so we can capture and report output
- bin <- R.home("bin")
- exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R"
- r <- file.path(bin, exe)
- args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball))
- output <- system2(r, args, stdout = TRUE, stderr = TRUE)
- message("Done!")
-
- # check for successful install
- status <- attr(output, "status")
- if (is.numeric(status) && !identical(status, 0L)) {
- header <- "Error installing renv:"
- lines <- paste(rep.int("=", nchar(header)), collapse = "")
- text <- c(header, lines, output)
- writeLines(text, con = stderr())
- }
-
- status
-
- }
-
- renv_bootstrap_prefix <- function() {
-
- # construct version prefix
- version <- paste(R.version$major, R.version$minor, sep = ".")
- prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-")
-
- # include SVN revision for development versions of R
- # (to avoid sharing platform-specific artefacts with released versions of R)
- devel <-
- identical(R.version[["status"]], "Under development (unstable)") ||
- identical(R.version[["nickname"]], "Unsuffered Consequences")
-
- if (devel)
- prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r")
-
- # build list of path components
- components <- c(prefix, R.version$platform)
-
- # include prefix if provided by user
- prefix <- Sys.getenv("RENV_PATHS_PREFIX")
- if (nzchar(prefix))
- components <- c(prefix, components)
-
- # build prefix
- paste(components, collapse = "/")
-
- }
-
- renv_bootstrap_library_root_name <- function(project) {
-
- # use project name as-is if requested
- asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE")
- if (asis)
- return(basename(project))
-
- # otherwise, disambiguate based on project's path
- id <- substring(renv_bootstrap_hash_text(project), 1L, 8L)
- paste(basename(project), id, sep = "-")
-
- }
-
- renv_bootstrap_library_root <- function(project) {
-
- path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA)
- if (!is.na(path))
- return(path)
-
- path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA)
- if (!is.na(path)) {
- name <- renv_bootstrap_library_root_name(project)
- return(file.path(path, name))
- }
-
- file.path(project, "renv/library")
-
- }
-
- renv_bootstrap_validate_version <- function(version) {
-
- loadedversion <- utils::packageDescription("renv", fields = "Version")
- if (version == loadedversion)
- return(TRUE)
-
- # assume four-component versions are from GitHub; three-component
- # versions are from CRAN
- components <- strsplit(loadedversion, "[.-]")[[1]]
- remote <- if (length(components) == 4L)
- paste("rstudio/renv", loadedversion, sep = "@")
- else
- paste("renv", loadedversion, sep = "@")
-
- fmt <- paste(
- "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.",
- "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.",
- "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.",
- sep = "\n"
- )
-
- msg <- sprintf(fmt, loadedversion, version, remote)
- warning(msg, call. = FALSE)
-
- FALSE
-
- }
-
- renv_bootstrap_hash_text <- function(text) {
-
- hashfile <- tempfile("renv-hash-")
- on.exit(unlink(hashfile), add = TRUE)
-
- writeLines(text, con = hashfile)
- tools::md5sum(hashfile)
-
- }
-
- renv_bootstrap_load <- function(project, libpath, version) {
-
- # try to load renv from the project library
- if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE))
- return(FALSE)
-
- # warn if the version of renv loaded does not match
- renv_bootstrap_validate_version(version)
-
- # load the project
- renv::load(project)
-
- TRUE
-
- }
-
- # construct path to library root
- root <- renv_bootstrap_library_root(project)
-
- # construct library prefix for platform
- prefix <- renv_bootstrap_prefix()
-
- # construct full libpath
- libpath <- file.path(root, prefix)
-
- # attempt to load
- if (renv_bootstrap_load(project, libpath, version))
- return(TRUE)
-
- # load failed; inform user we're about to bootstrap
- prefix <- paste("# Bootstrapping renv", version)
- postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "")
- header <- paste(prefix, postfix)
- message(header)
-
- # perform bootstrap
- bootstrap(version, libpath)
-
- # exit early if we're just testing bootstrap
- if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA)))
- return(TRUE)
-
- # try again to load
- if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) {
- message("* Successfully installed and loaded renv ", version, ".")
- return(renv::load())
- }
-
- # failed to download or load renv; warn the user
- msg <- c(
- "Failed to find an renv installation: the project will not be loaded.",
- "Use `renv::activate()` to re-initialize the project."
- )
-
- warning(paste(msg, collapse = "\n"), call. = FALSE)
-
-})
diff --git a/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml
index 364d47d..c97939a 100644
--- a/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml
+++ b/testing/resources/ruby_versioned_hooks_repo/.pre-commit-hooks.yaml
@@ -2,5 +2,5 @@
name: Ruby Hook
entry: ruby_hook
language: ruby
- language_version: 3.1.0
+ language_version: 3.2.0
files: \.rb$
diff --git a/testing/resources/swift_hooks_repo/.gitignore b/testing/resources/swift_hooks_repo/.gitignore
deleted file mode 100644
index 02c0875..0000000
--- a/testing/resources/swift_hooks_repo/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.DS_Store
-/.build
-/Packages
-/*.xcodeproj
diff --git a/testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml b/testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml
deleted file mode 100644
index c08df87..0000000
--- a/testing/resources/swift_hooks_repo/.pre-commit-hooks.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-- id: swift-hooks-repo
- name: Swift hooks repo example
- description: Runs the hello world app generated by swift package init --type executable (binary called swift_hooks_repo here)
- entry: swift_hooks_repo
- language: swift
- files: \.(swift)$
diff --git a/testing/resources/swift_hooks_repo/Package.swift b/testing/resources/swift_hooks_repo/Package.swift
deleted file mode 100644
index 04976d3..0000000
--- a/testing/resources/swift_hooks_repo/Package.swift
+++ /dev/null
@@ -1,7 +0,0 @@
-// swift-tools-version:5.0
-import PackageDescription
-
-let package = Package(
- name: "swift_hooks_repo",
- targets: [.target(name: "swift_hooks_repo")]
-)
diff --git a/testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift b/testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift
deleted file mode 100644
index f7cf60e..0000000
--- a/testing/resources/swift_hooks_repo/Sources/swift_hooks_repo/main.swift
+++ /dev/null
@@ -1 +0,0 @@
-print("Hello, world!")