summaryrefslogtreecommitdiffstats
path: root/pre_commit
diff options
context:
space:
mode:
Diffstat (limited to 'pre_commit')
-rw-r--r--pre_commit/commands/run.py8
-rw-r--r--pre_commit/languages/docker.py33
-rw-r--r--pre_commit/languages/r.py53
-rw-r--r--pre_commit/resources/empty_template_LICENSE.renv7
-rw-r--r--pre_commit/resources/empty_template_Makefile.PL2
-rw-r--r--pre_commit/resources/empty_template_activate.R440
-rw-r--r--pre_commit/resources/empty_template_go.mod2
-rw-r--r--pre_commit/resources/empty_template_package.json2
-rw-r--r--pre_commit/resources/empty_template_pre_commit_dummy_package.gemspec6
-rw-r--r--pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec6
-rw-r--r--pre_commit/resources/empty_template_setup.py2
-rw-r--r--pre_commit/resources/rbenv.tar.gzbin34250 -> 32678 bytes
-rw-r--r--pre_commit/resources/ruby-build.tar.gzbin74218 -> 68689 bytes
-rw-r--r--pre_commit/resources/ruby-download.tar.gzbin5533 -> 5271 bytes
-rw-r--r--pre_commit/store.py13
15 files changed, 534 insertions, 40 deletions
diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py
index 05c3268..0fef50d 100644
--- a/pre_commit/commands/run.py
+++ b/pre_commit/commands/run.py
@@ -271,11 +271,11 @@ def _get_diff() -> bytes:
def _run_hooks(
config: Dict[str, Any],
hooks: Sequence[Hook],
+ skips: Set[str],
args: argparse.Namespace,
environ: MutableMapping[str, str],
) -> int:
"""Actually run the hooks."""
- skips = _get_skips(environ)
cols = _compute_cols(hooks)
classifier = Classifier.from_config(
_all_filenames(args), config['files'], config['exclude'],
@@ -403,9 +403,11 @@ def run(
)
return 1
- install_hook_envs(hooks, store)
+ skips = _get_skips(environ)
+ to_install = [hook for hook in hooks if hook.id not in skips]
+ install_hook_envs(to_install, store)
- return _run_hooks(config, hooks, args, environ)
+ return _run_hooks(config, hooks, skips, args, environ)
# https://github.com/python/mypy/issues/7726
raise AssertionError('unreachable')
diff --git a/pre_commit/languages/docker.py b/pre_commit/languages/docker.py
index 9d30568..5b21ec9 100644
--- a/pre_commit/languages/docker.py
+++ b/pre_commit/languages/docker.py
@@ -1,5 +1,7 @@
import hashlib
+import json
import os
+import socket
from typing import Sequence
from typing import Tuple
@@ -8,6 +10,7 @@ from pre_commit.hook import Hook
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
from pre_commit.util import clean_path_on_failure
+from pre_commit.util import cmd_output_b
ENVIRONMENT_DIR = 'docker'
PRE_COMMIT_LABEL = 'PRE_COMMIT'
@@ -15,6 +18,34 @@ get_default_version = helpers.basic_get_default_version
healthy = helpers.basic_healthy
+def _is_in_docker() -> bool:
+ try:
+ with open('/proc/1/cgroup', 'rb') as f:
+ return b'docker' in f.read()
+ except FileNotFoundError:
+ return False
+
+
+def _get_docker_path(path: str) -> str:
+ if not _is_in_docker():
+ return path
+ hostname = socket.gethostname()
+
+ _, out, _ = cmd_output_b('docker', 'inspect', hostname)
+
+ container, = json.loads(out)
+ for mount in container['Mounts']:
+ src_path = mount['Source']
+ to_path = mount['Destination']
+ if os.path.commonpath((path, to_path)) == to_path:
+ # So there is something in common,
+ # and we can proceed remapping it
+ return path.replace(to_path, src_path)
+ # we're in Docker, but the path is not mounted, cannot really do anything,
+ # so fall back to original path
+ return path
+
+
def md5(s: str) -> str: # pragma: win32 no cover
return hashlib.md5(s.encode()).hexdigest()
@@ -73,7 +104,7 @@ def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
# https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
# The `Z` option tells Docker to label the content with a private
# unshared label. Only the current container can use a private volume.
- '-v', f'{os.getcwd()}:/src:rw,Z',
+ '-v', f'{_get_docker_path(os.getcwd())}:/src:rw,Z',
'--workdir', '/src',
)
diff --git a/pre_commit/languages/r.py b/pre_commit/languages/r.py
index 83e6000..d573775 100644
--- a/pre_commit/languages/r.py
+++ b/pre_commit/languages/r.py
@@ -15,6 +15,7 @@ from pre_commit.util import clean_path_on_failure
from pre_commit.util import cmd_output_b
ENVIRONMENT_DIR = 'renv'
+RSCRIPT_OPTS = ('--no-save', '--no-restore', '--no-site-file', '--no-environ')
get_default_version = helpers.basic_get_default_version
healthy = helpers.basic_healthy
@@ -39,14 +40,19 @@ def _get_env_dir(prefix: Prefix, version: str) -> str:
return prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version))
-def _prefix_if_file_entry(
+def _prefix_if_non_local_file_entry(
entry: Sequence[str],
prefix: Prefix,
+ src: str,
) -> Sequence[str]:
if entry[1] == '-e':
return entry[1:]
else:
- return (prefix.path(entry[1]),)
+ if src == 'local':
+ path = entry[1]
+ else:
+ path = prefix.path(entry[1])
+ return (path,)
def _entry_validate(entry: Sequence[str]) -> None:
@@ -69,13 +75,12 @@ def _entry_validate(entry: Sequence[str]) -> None:
def _cmd_from_hook(hook: Hook) -> Tuple[str, ...]:
- opts = ('--no-save', '--no-restore', '--no-site-file', '--no-environ')
entry = shlex.split(hook.entry)
_entry_validate(entry)
return (
- *entry[:1], *opts,
- *_prefix_if_file_entry(entry, hook.prefix),
+ *entry[:1], *RSCRIPT_OPTS,
+ *_prefix_if_non_local_file_entry(entry, hook.prefix, hook.src),
*hook.args,
)
@@ -89,29 +94,32 @@ def install_environment(
with clean_path_on_failure(env_dir):
os.makedirs(env_dir, exist_ok=True)
shutil.copy(prefix.path('renv.lock'), env_dir)
+ shutil.copytree(prefix.path('renv'), os.path.join(env_dir, 'renv'))
cmd_output_b(
'Rscript', '--vanilla', '-e',
f"""\
prefix_dir <- {prefix.prefix_dir!r}
- missing_pkgs <- setdiff(
- "renv", unname(installed.packages()[, "Package"])
- )
options(
repos = c(CRAN = "https://cran.rstudio.com"),
renv.consent = TRUE
)
- install.packages(missing_pkgs)
- renv::activate()
+ source("renv/activate.R")
renv::restore()
activate_statement <- paste0(
- 'renv::activate("', file.path(getwd()), '"); '
+ 'suppressWarnings({{',
+ 'old <- setwd("', getwd(), '"); ',
+ 'source("renv/activate.R"); ',
+ 'setwd(old); ',
+ 'renv::load("', getwd(), '");}})'
)
writeLines(activate_statement, 'activate.R')
- is_package <- tryCatch({{
- content_desc <- read.dcf(file.path(prefix_dir, 'DESCRIPTION'))
- suppressWarnings(unname(content_desc[,'Type']) == "Package")
- }},
- error = function(...) FALSE
+ is_package <- tryCatch(
+ {{
+ path_desc <- file.path(prefix_dir, 'DESCRIPTION')
+ suppressWarnings(desc <- read.dcf(path_desc))
+ "Package" %in% colnames(desc)
+ }},
+ error = function(...) FALSE
)
if (is_package) {{
renv::install(prefix_dir)
@@ -120,12 +128,13 @@ def install_environment(
cwd=env_dir,
)
if additional_dependencies:
- cmd_output_b(
- 'Rscript', '-e',
- 'renv::install(commandArgs(trailingOnly = TRUE))',
- *additional_dependencies,
- cwd=env_dir,
- )
+ with in_env(prefix, version):
+ cmd_output_b(
+ 'Rscript', *RSCRIPT_OPTS, '-e',
+ 'renv::install(commandArgs(trailingOnly = TRUE))',
+ *additional_dependencies,
+ cwd=env_dir,
+ )
def run_hook(
diff --git a/pre_commit/resources/empty_template_LICENSE.renv b/pre_commit/resources/empty_template_LICENSE.renv
new file mode 100644
index 0000000..253c5d1
--- /dev/null
+++ b/pre_commit/resources/empty_template_LICENSE.renv
@@ -0,0 +1,7 @@
+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/pre_commit/resources/empty_template_Makefile.PL b/pre_commit/resources/empty_template_Makefile.PL
index ac75fe5..45a0ba3 100644
--- a/pre_commit/resources/empty_template_Makefile.PL
+++ b/pre_commit/resources/empty_template_Makefile.PL
@@ -1,6 +1,6 @@
use ExtUtils::MakeMaker;
WriteMakefile(
- NAME => "PreCommitDummy",
+ NAME => "PreCommitPlaceholder",
VERSION => "0.0.1",
);
diff --git a/pre_commit/resources/empty_template_activate.R b/pre_commit/resources/empty_template_activate.R
new file mode 100644
index 0000000..d8d092c
--- /dev/null
+++ b/pre_commit/resources/empty_template_activate.R
@@ -0,0 +1,440 @@
+
+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/pre_commit/resources/empty_template_go.mod b/pre_commit/resources/empty_template_go.mod
index de3e241..892c4e5 100644
--- a/pre_commit/resources/empty_template_go.mod
+++ b/pre_commit/resources/empty_template_go.mod
@@ -1 +1 @@
-module pre-commit-dummy-empty-module
+module pre-commit-placeholder-empty-module
diff --git a/pre_commit/resources/empty_template_package.json b/pre_commit/resources/empty_template_package.json
index ac7b725..042e958 100644
--- a/pre_commit/resources/empty_template_package.json
+++ b/pre_commit/resources/empty_template_package.json
@@ -1,4 +1,4 @@
{
- "name": "pre_commit_dummy_package",
+ "name": "pre_commit_placeholder_package",
"version": "0.0.0"
}
diff --git a/pre_commit/resources/empty_template_pre_commit_dummy_package.gemspec b/pre_commit/resources/empty_template_pre_commit_dummy_package.gemspec
deleted file mode 100644
index 8bfb40c..0000000
--- a/pre_commit/resources/empty_template_pre_commit_dummy_package.gemspec
+++ /dev/null
@@ -1,6 +0,0 @@
-Gem::Specification.new do |s|
- s.name = 'pre_commit_dummy_package'
- s.version = '0.0.0'
- s.summary = 'dummy gem for pre-commit hooks'
- s.authors = ['Anthony Sottile']
-end
diff --git a/pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec b/pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec
new file mode 100644
index 0000000..630f0d4
--- /dev/null
+++ b/pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec
@@ -0,0 +1,6 @@
+Gem::Specification.new do |s|
+ s.name = 'pre_commit_placeholder_package'
+ s.version = '0.0.0'
+ s.summary = 'placeholder gem for pre-commit hooks'
+ s.authors = ['Anthony Sottile']
+end
diff --git a/pre_commit/resources/empty_template_setup.py b/pre_commit/resources/empty_template_setup.py
index 6886064..ef05eef 100644
--- a/pre_commit/resources/empty_template_setup.py
+++ b/pre_commit/resources/empty_template_setup.py
@@ -1,4 +1,4 @@
from setuptools import setup
-setup(name='pre-commit-dummy-package', version='0.0.0')
+setup(name='pre-commit-placeholder-package', version='0.0.0')
diff --git a/pre_commit/resources/rbenv.tar.gz b/pre_commit/resources/rbenv.tar.gz
index 95b5a36..98b7e0f 100644
--- a/pre_commit/resources/rbenv.tar.gz
+++ b/pre_commit/resources/rbenv.tar.gz
Binary files differ
diff --git a/pre_commit/resources/ruby-build.tar.gz b/pre_commit/resources/ruby-build.tar.gz
index ef82e2f..afec5db 100644
--- a/pre_commit/resources/ruby-build.tar.gz
+++ b/pre_commit/resources/ruby-build.tar.gz
Binary files differ
diff --git a/pre_commit/resources/ruby-download.tar.gz b/pre_commit/resources/ruby-download.tar.gz
index 2e19507..92502a7 100644
--- a/pre_commit/resources/ruby-download.tar.gz
+++ b/pre_commit/resources/ruby-download.tar.gz
Binary files differ
diff --git a/pre_commit/store.py b/pre_commit/store.py
index 187c9d3..0fd5e62 100644
--- a/pre_commit/store.py
+++ b/pre_commit/store.py
@@ -188,15 +188,20 @@ class Store:
LOCAL_RESOURCES = (
'Cargo.toml', 'main.go', 'go.mod', 'main.rs', '.npmignore',
- 'package.json', 'pre_commit_dummy_package.gemspec', 'setup.py',
- 'environment.yml', 'Makefile.PL', 'renv.lock',
+ 'package.json', 'pre_commit_placeholder_package.gemspec', 'setup.py',
+ 'environment.yml', 'Makefile.PL',
+ 'renv.lock', 'renv/activate.R', 'renv/LICENSE.renv',
)
def make_local(self, deps: Sequence[str]) -> str:
def make_local_strategy(directory: str) -> None:
for resource in self.LOCAL_RESOURCES:
- contents = resource_text(f'empty_template_{resource}')
- with open(os.path.join(directory, resource), 'w') as f:
+ resource_dirname, resource_basename = os.path.split(resource)
+ contents = resource_text(f'empty_template_{resource_basename}')
+ target_dir = os.path.join(directory, resource_dirname)
+ target_file = os.path.join(target_dir, resource_basename)
+ os.makedirs(target_dir, exist_ok=True)
+ with open(target_file, 'w') as f:
f.write(contents)
env = git.no_git_env()