# Path: shipwright/_lib/cli.py
# def argparser():
#     def a_arg(parser, *args, **kwargs):
# def parse_registry_logins(registry_logins):
# def _flatten(items):
# def old_style_arg_dict(namespace):
# def main():
# def process_arguments(path, arguments, client_cfg, environ):
#     def default(self, obj):
# def run(path, arguments, client_cfg, environ, new_style_args=None):
# def exit(msg):
# def memo(f, arg, memos={}):
# def pretty_event(evt, show_progress):
# def highlight(name):
#     def highlight_(msg):
# def switch(rec, show_progress):
# class SetJSONEncoder(json.JSONEncoder):
# 
# Path: tests/integration/utils.py
# def commit_untracked(repo, message='WIP'):
#     repo.index.add(repo.untracked_files)
#     repo.index.commit(message)
# 
# def create_repo(path, source=None):
#     if source is not None:
#         shutil.copytree(source, path)
#     repo = git.Repo.init(path)
#     repo.index.add(repo.untracked_files)
#     repo.index.commit('Initial Commit')
#     return repo
# 
# def default_args():
#     return argparse.Namespace(
#         dirty=False,
#         pull_cache=False,
#         registry_login=[],
#     )
# 
# def get_defaults():
#     return {
#         '--account': None,
#         '--dependents': [],
#         '--dump-file': None,
#         '--exact': [],
#         '--exclude': [],
#         '--help': False,
#         '--no-build': False,
#         '--dirty': False,
#         '--upto': [],
#         '--x-assert-hostname': False,
#         '-H': None,
#         'TARGET': [],
#         'build': False,
#         'push': False,
#         'images': False,
#         'tags': ['latest'],
#     }


import json
import pkg_resources
import pytest
from docker import utils as docker_utils
from shipwright._lib import cli as shipw_cli
from .utils import commit_untracked, create_repo, default_args, get_defaults
        }

        assert set(service1['RepoTags']) == {
            'shipwright/service1:master',
            'shipwright/service1:latest',
            'shipwright/service1:' + tag,
        }

        assert set(base['RepoTags']) == {
            'shipwright/base:master',
            'shipwright/base:latest',
            'shipwright/base:' + tag,
        }
    finally:
        old_images = (
            cli.images(name='shipwright/service1-dev', quiet=True) +
            cli.images(name='shipwright/service1', quiet=True) +
            cli.images(name='shipwright/base', quiet=True)
        )
        for image in old_images:
            cli.remove_image(image, force=True)


def test_clean_tree_avoids_rebuild(tmpdir, docker_client):
    tmp = tmpdir.join('shipwright-sample')
    path = str(tmp)
    source = pkg_resources.resource_filename(
        __name__,
        'examples/shipwright-sample',
    )

# Path: shipwright/_lib/cli.py
# def argparser():
#     def a_arg(parser, *args, **kwargs):
# def parse_registry_logins(registry_logins):
# def _flatten(items):
# def old_style_arg_dict(namespace):
# def main():
# def process_arguments(path, arguments, client_cfg, environ):
#     def default(self, obj):
# def run(path, arguments, client_cfg, environ, new_style_args=None):
# def exit(msg):
# def memo(f, arg, memos={}):
# def pretty_event(evt, show_progress):
# def highlight(name):
#     def highlight_(msg):
# def switch(rec, show_progress):
# class SetJSONEncoder(json.JSONEncoder):
# 
# Path: tests/integration/utils.py
# def commit_untracked(repo, message='WIP'):
#     repo.index.add(repo.untracked_files)
#     repo.index.commit(message)
# 
# def create_repo(path, source=None):
#     if source is not None:
#         shutil.copytree(source, path)
#     repo = git.Repo.init(path)
#     repo.index.add(repo.untracked_files)
#     repo.index.commit('Initial Commit')
#     return repo
# 
# def default_args():
#     return argparse.Namespace(
#         dirty=False,
#         pull_cache=False,
#         registry_login=[],
#     )
# 
# def get_defaults():
#     return {
#         '--account': None,
#         '--dependents': [],
#         '--dump-file': None,
#         '--exact': [],
#         '--exclude': [],
#         '--help': False,
#         '--no-build': False,
#         '--dirty': False,
#         '--upto': [],
#         '--x-assert-hostname': False,
#         '-H': None,
#         'TARGET': [],
#         'build': False,
#         'push': False,
#         'images': False,
#         'tags': ['latest'],
#     }


# Path: tests/integration/test_docker_builds.py
import json
import pkg_resources
import pytest
from docker import utils as docker_utils
from shipwright._lib import cli as shipw_cli
from .utils import commit_untracked, create_repo, default_args, get_defaults

        }

        assert set(service1['RepoTags']) == {
            'shipwright/service1:master',
            'shipwright/service1:latest',
            'shipwright/service1:' + tag,
        }

        assert set(base['RepoTags']) == {
            'shipwright/base:master',
            'shipwright/base:latest',
            'shipwright/base:' + tag,
        }
    finally:
        old_images = (
            cli.images(name='shipwright/service1-dev', quiet=True) +
            cli.images(name='shipwright/service1', quiet=True) +
            cli.images(name='shipwright/base', quiet=True)
        )
        for image in old_images:
            cli.remove_image(image, force=True)


def test_clean_tree_avoids_rebuild(tmpdir, docker_client):
    tmp = tmpdir.join('shipwright-sample')
    path = str(tmp)
    source = pkg_resources.resource_filename(
        __name__,
        'examples/shipwright-sample',
    )

    repo = create_repo(path, source)