Skip to content

Commit 4f996c9

Browse files
committed
Improve logging in Repository.update()
1 parent 8a9117e commit 4f996c9

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

vcs_repo_mgr/__init__.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -800,25 +800,26 @@ def update(self, remote=None):
800800
.. note:: Automatically creates the local repository on the first run.
801801
"""
802802
remote = remote or self.remote
803+
update_limit = int(os.environ.get(UPDATE_VARIABLE, '0'))
803804
if not remote:
804-
# If there is no remote configured, there's nothing we can do!
805-
return
806-
if self.create(remote=remote):
805+
# If there's no remote there's nothing we can do!
806+
logger.debug("Skipping update (pull) because there's no remote.")
807+
elif self.create(remote=remote):
807808
# If the local clone didn't exist yet and we just created it,
808809
# we can skip the update (since there's no point).
809-
return
810-
global_last_update = int(os.environ.get(UPDATE_VARIABLE, '0'))
811-
if global_last_update and self.last_updated >= global_last_update:
810+
logger.debug("Skipping update (pull) because local repository was just created.")
811+
elif update_limit and self.last_updated >= update_limit:
812812
# If an update limit has been enforced we also skip the update.
813-
return
814-
logger.info("Pulling %s updates from %s into %s ..", self.friendly_name, remote, self.local)
815-
execute(self.get_command(
816-
method_name='update',
817-
attribute_name='update_command',
818-
local=self.local,
819-
remote=remote,
820-
))
821-
self.mark_updated()
813+
logger.debug("Skipping update (pull) due to update limit.")
814+
else:
815+
logger.info("Pulling %s updates from %s into %s ..", self.friendly_name, remote, self.local)
816+
execute(self.get_command(
817+
method_name='update',
818+
attribute_name='update_command',
819+
local=self.local,
820+
remote=remote,
821+
))
822+
self.mark_updated()
822823

823824
def checkout(self, revision=None, clean=False):
824825
"""

0 commit comments

Comments
 (0)