Skip to content

Commit

Permalink
Fail quietly when updating from a tag [0.1.x backport]
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored Aug 24, 2020
1 parent 58000fb commit 2d8004b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
9 changes: 5 additions & 4 deletions core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ def push(self):
def pull(self):
return self._run_command_on_target_tree('pull')

@defer.inlineCallbacks
def update(self):
yield self._update_manager.update()
return self._update_manager.update()

@defer.inlineCallbacks
def serialize(self):
Expand Down Expand Up @@ -353,6 +352,8 @@ def _get_next_dependent_target(self, parent_target):
def _enforce_no_store_true_args(parser):
for action in parser._actions:
if isinstance(action, argparse._StoreTrueAction):
error_msg = 'manofest.py doens\'t support argument registration of type=\'store_true\' \n' + \
'offending action={0}'.format(action)
error_msg = (
'manofest.py doens\'t support argument registration of'
' type=\'store_true\' \noffending action={0}'.format(action)
)
raise SyntaxError(error_msg)
14 changes: 13 additions & 1 deletion core/update_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ def update(self):
sys.stdout.flush()

# try to update by simply pulling whatever branch / remote we're on
out, _, _ = yield manof.utils.git_pull(self._logger, self._manof_path)
out, err, exit_code = yield manof.utils.git_pull(
self._logger, self._manof_path, quiet=True
)
if exit_code:
if 'You are not currently on a branch' in err:
sys.stdout.write(
'Skipping updating manof (checkout to a specific branch first)'
)
return
self._logger.error(
'Failed to update manof', exit_code=exit_code, err=err, out=out
)
raise RuntimeError('Failed to update manof')

# if "up-to-date" was not outputted, this means that we updated - return True in this case
updated = 'up-to-date' not in out
Expand Down
4 changes: 2 additions & 2 deletions manof/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def err(self):
return self._err


def git_pull(logger, path):
def git_pull(logger, path, quiet=False):
logger.debug('Pulling', **locals())
return shell_run(logger, 'git pull', cwd=path)
return shell_run(logger, 'git pull', cwd=path, quiet=quiet)


@defer.inlineCallbacks
Expand Down
12 changes: 9 additions & 3 deletions tools/flake8_plugin/flake8_igz.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ def get_string_tokens(tokens):


def single_quote_strings(logical_line, tokens):
for lexeme, start, _, in Utils.get_string_tokens(tokens):
for lexeme, start, _, in Utils.get_string_tokens(
tokens
):
if lexeme.startswith('"') and not lexeme.startswith('"""'):
yield start, 'I100 double-quote string used (expected single-quote)'


def multiline_string_on_newline(logical_line, tokens):
for lexeme, start, end, in Utils.get_string_tokens(tokens):
for lexeme, start, end, in Utils.get_string_tokens(
tokens
):
if lexeme.startswith('"""'):
if not re.match(r'^\"\"\"\n', lexeme):
yield start, 'I101 multiline string must start on next line after triple double-quotes'
Expand All @@ -35,7 +39,9 @@ def multiline_string_on_newline(logical_line, tokens):


def multiline_string_double_quotes(logical_line, tokens):
for lexeme, start, _, in Utils.get_string_tokens(tokens):
for lexeme, start, _, in Utils.get_string_tokens(
tokens
):
if lexeme.startswith('\'\'\''):
yield start, 'I103 triple single-quotes used in multiline string (expected triple double-quotes)'

Expand Down

0 comments on commit 2d8004b

Please sign in to comment.