Probably only the first of these is needed, because it was
guarding os.makedirs(path) against os.path.exists(path / 'HEAD').
This was causing an error on Windows:
```
C:\dev\dotfiles>peru sync
Traceback (most recent call last):
File "C:\Python36\Scripts\peru-script.py", line 11, in <module>
load_entry_point('peru==1.1.0', 'console_scripts', 'peru')()
File "C:\Python36\lib\site-packages\peru\main.py", line 363, in main
runtime = async.run_task(Runtime(args, env))
File "C:\Python36\lib\site-packages\peru\async.py", line 29, in run_task
return asyncio.get_event_loop().run_until_complete(coro)
File "C:\Python36\lib\asyncio\base_events.py", line 466, in run_until_complete
return future.result()
File "C:\Python36\lib\site-packages\peru\runtime.py", line 20, in Runtime
yield from r._init_cache()
File "C:\Python36\lib\site-packages\peru\runtime.py", line 63, in _init_cache
self.cache = yield from cache.Cache(self.cache_dir)
File "C:\Python36\lib\site-packages\peru\cache.py", line 251, in Cache
yield from cache._init_trees()
File "C:\Python36\lib\site-packages\peru\cache.py", line 270, in _init_trees
os.makedirs(self.trees_path)
File "C:\Python36\lib\os.py", line 220, in makedirs
mkdir(name, mode)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\\dev\\dotfiles\\.peru\\cache\\trees'
```
Invalid escapes like '\s' used to silently turn into a literal '\s', but
in Python 3.6 they became a deprecation warning, and eventually they'll
be an error.
Changes since 1.0.0:
- Proper error handling. Errors during sync used to kill the entire
process, which spammed the terminal with unfinished coroutine
warnings. Now we catch those errors and print them properly at the
end.
- Cleaned up plugin errors. Common errors like "the network is down" no
longer have stacktraces cluttering them up.
Changes since 0.4.0:
- Add the `drop` rule field.
- Add the `submodules` field to the git plugin, to disable recursive
submodule fetching.
- Add a warning when overrides are configured but unused.
- Skip directories named .peru in module sources, similar to how git
skips directories named .git.
- Fix a bug with partially defined git submodules.
Normally when you run `git submodule add ...`, git puts two things in
your repo: an entry in .gitmodules, and a commit object at the
appropriate path inside your repo. However, it's possible for those two
to get out of sync, especially if you use mv/rm on a directory followed
by `git add`, instead of the smarter `git mv`/`git rm`. If we run into
one of these missing submodules, just skip it.
Fixes https://github.com/buildinspace/peru/issues/157.
This tests that when a recursive override is added (e.g. "A.B"), it
overrides both direct imports of "A.B" and also interior imports of "B"
in module "A". It turns out we were already doing this correctly, though
I honestly expected we weren't :p
Closes https://github.com/buildinspace/peru/issues/89.
Dropping everything in a tree was causing modify_tree() to return None,
which lead to a different error when we tried to pass that None back to
git as though it was a valid tree. In retrospect, representing the empty
tree as None was not smart on my part. This diff fixes the modify_tree()
case, though others remain...