Assert if Linter is not run from repo root
Currently if Linter is run not from the repo root, it will fail because it will compose an incorrect path to the env file and won't be able to find it. E.g. running from docs/:
Couldn't find env file: /data/sonyan/src/helpers1/docs/devops/env/default.env
We should put an assertion in the code to make it clearer for the user that the error is because Linter is run from the wrong directory and they should just run from the repo root to fix it.
Makes sense.
The only thing is that sometimes I run from the root of cmamp and sometimes from the root of helpers and they both work (although probably pick a different file but it doesn't make a difference).
In any case I'm ok to force running from the top of the outermost repo.
FYI @heanhsok
The only thing is that sometimes I run from the root of cmamp and sometimes from the root of helpers and they both work (although probably pick a different file but it doesn't make a difference).
Yes, correct, Linter will run fine if it is run from the root of the repo one is developing in, be it helpers, cmamp, or any other repo.
@Peeyush4 helpful functions regarding checking for repo root should be found in helpers/hgit.py
Maybe the fix is
create a function like
def is_cwd_git_repo():
return os.path.exists(".git")
and then a dassert on that
The invariant is that in any repo (super and sub) there is a git file or dir.
Done