[blivet:master 2/3] Don't run test if the git branch is dirty

Vratislav Podzimek vpodzime at redhat.com
Fri Mar 28 08:43:23 UTC 2014


On Thu, 2014-03-27 at 12:45 -0400, mulhern wrote:
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
>  scripts/pylintcodediff | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/scripts/pylintcodediff b/scripts/pylintcodediff
> index 89bfefe..0bf59e0 100755
> --- a/scripts/pylintcodediff
> +++ b/scripts/pylintcodediff
> @@ -31,6 +31,9 @@ def make_parser(parser):
>      parser.add_argument('--branch',
>         default='pylint-code-diff-test',
>         help='name of test branch')
> +    parser.add_argument('--force',
> +       action='store_true',
> +       help='run anyway')
>      parser.add_argument('--pylint-log',
>         default='pylint-log',
>         help='path to pylint log')
> @@ -111,6 +114,24 @@ def diff_quality(pylint_file):
>  
>      print(stdoutdata)
>  
> +def clean():
> +    """ Checks whether git detects some changes in the current branch.
> +
> +        :return: True if git finds no changes, otherwise False
> +        :rtype: bool
> +    """
> +    command = [ 'git', 'diff-index', '--exit-code', '--cached', 'HEAD' ]
> +    (stdoutdata, stderrdata, ret) = run_command(command)
> +    if ret != 0:
> +        return False
> +
> +    command = [ 'git', 'diff-files', '--exit-code' ]
> +    (stdoutdata, stderrdata, ret) = run_command(command)
> +    if ret != 0:
> +        return False
> +
> +    return True
> +
>  def main():
>      parser = argparse.ArgumentParser(description="Find pylint messages related to changes subsequent to given commit.")
>      make_parser(parser)
> @@ -119,6 +140,11 @@ def main():
>  
>      branch = args.branch
>      commit = args.commit
> +    force = args.force
> +
> +    if not force and not clean():
> +        sys.exit("Your working branch has some changes that may be lost while running this test. Use the --force flag to proceed anyway.")
Please split this line into multiple shorter lines.

ACK otherwise.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list