This commit moves `HashedStreamReader`/`get_hash_file`/`file_md5`
into `dvc.objects.hash`.
The `get_hash_file` has been renamed to `hash_file`.
This also copies `relpath` and `is_exec` to the `dvc.fs.utils`.
scm.install does 3 different things, and all of those are
very much tied to DVC. So, as we are splitting scm out,
it should now belong to `dvc.install`.
* pygit2: implement get/set/remove refs
* pygit: implement iter_refs
* pygit: implement resolve_rev
* pygit2: implement working tree checkout
* pygit2: implement reset, explicitly read/write index when used
* pygit2: checkout does not need to reset index
* pygit2: handle "-" branch shorthand in checkout
* tests: install post-checkout hook should be run via gitpython
* exp apply: use stricter exception handling for merge conflict
* pygit: fix index read/write usage
* gitpython: handle untracked file conflicts in stash apply
* fix flaky/race index issue
* drop python 3.5 support
* dvc: remove fspath() use inside os.path calls
* dvc: replace dvc.compat.fspath with os.fspath
* tests: replace dvc.compat.fspath with os.fspath
* utils: relpath() should use fspath/str
* utils: os.readlink doesn't support path-like obj on Windows until 3.8
* Initial design of using pre-commit for Git hooks
* Refactor to reuse existing code and provide merge capabilities
* Linter fixes
* More cleanup
* scm: make use_precommit_tool optional
* dvc: install our own hooks
* install: fix typo
* install: fix bugs in pre-commit integration
* install: don't forget 'always_run' for post-checkout
* install: no need to run pre-commit install if conf file doesn't exist
* install: fix bugs
* install: use python hooks
* add .pre-commit-hooks.yaml
Co-authored-by: Andrew Hare <[email protected]>
Co-authored-by: Ruslan Kuprieiev <[email protected]>
* dvc: refactor config
Advantages:
- read like a dict
- modify as a dict for testing or manipulation purposes
- wrap modifications into context manager to save them:
with config.edit("local") as conf:
conf["core"]["remote"] = "new-default"
Design decisions:
- dropped string constants
- remote sections are parsed into a simple subdict upon load
- remote config schema is now defined by url scheme
- relative paths are handled transparently upon load/save
- user config and remote manipulations are moved to commands
- same dev manipulations are done by simply modifying a config dict
* test: do not set cache.type for remotes that doesn't support it
* dvc: fix windows absolute paths validation in config
* test: fix windows separate drive test
* dvc: stylistic fixes in config
* dvc: hooks only act in branches where dvc active
In a branch where DVC hasn't been initialized (as detected by
`git ls-files .dvc` not listing any files), don't invoke dvc in the git hooks.
This avoids trouble when switching between branches with and without dvc
initialized.
Fixes#2208
* dvc: simplify hooks per PR comment