diff --git a/docs/ref/cli.rst b/docs/ref/cli.rst index 3ea27fd..794a16e 100644 --- a/docs/ref/cli.rst +++ b/docs/ref/cli.rst @@ -60,6 +60,12 @@ Performs a ``git pull`` in each of the repositories registered with `homely add`_, runs all of their ``HOMELY.py`` scripts, and then performs :any:`automatic cleanup ` as necessary. +If `HOMELY_PULL_WHEN_DIRTY=1` is present in the environment, then homely will attempt to use `git +pull` in the registered repositories even if they have uncommitted changes. This behaviour will +eventually become the default. You can avoid merge conflicts from pulls in your repositories by +running `git config pull.ff only` in each of your repositories, of using `git config --global +pull.ff only` to set this option globally. + ``homely update [OPTIONS] [REPO ...]`` ``REPO`` diff --git a/homely/_ui.py b/homely/_ui.py index 2eaa4bb..5bad126 100644 --- a/homely/_ui.py +++ b/homely/_ui.py @@ -140,6 +140,8 @@ def run_update(infos, pullfirst, only=None, cancleanup=None, quick=None): if os.path.exists(FAILFILE): os.unlink(FAILFILE) + must_abort_when_dirty = os.getenv("HOMELY_PULL_WHEN_DIRTY", "0") != "1" + try: # write the section file with the current section name _write(SECTIONFILE, "") @@ -157,8 +159,9 @@ def run_update(infos, pullfirst, only=None, cancleanup=None, quick=None): if pullfirst: with note("Pulling changes for {}".format( localrepo.repo_path)): - if localrepo.isdirty(): + if must_abort_when_dirty and localrepo.isdirty(): dirty("Aborting - uncommitted changes") + dirty("(use HOMELY_PULL_WHEN_DIRTY=1 to override)") else: try: localrepo.pullchanges()