# Path: shipwright/_lib/source_control.py
# def source_control(path, namespace, name_map, mode=None):
#     if mode is None:
#         mode = AUTO
#     assert isinstance(mode, Mode)
#     the_mode = mode if mode is not AUTO else get_mode(path)
#     for cls in SourceControl.__subclasses__():
#         if cls.mode is the_mode:
#             return cls(path, namespace, name_map)
# 
# 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


import pkg_resources
import pytest
from shipwright._lib import source_control
from .utils import commit_untracked, create_repo
    tmp.join('service2/Dockerfile').write('FROM busybox\n')
    assert scm.is_dirty()

    new_refs = _refs(scm.targets())
    new_ref_str = scm.this_ref_str()

    dirty_suffix = '-dirty-f2f0df80ff0f'
    service2_tag = 'g' * 12 + dirty_suffix
    assert new_refs['shipwright/base'] == tag
    assert new_refs['shipwright/shared'] == tag
    assert new_refs['shipwright/service1'] == tag
    assert new_refs['shipwright/service2'] == service2_tag

    assert new_refs == {
        'shipwright/base': tag,
        'shipwright/service1': tag,
        'shipwright/shared': tag,
        'shipwright/service2': service2_tag,
    }
    assert old_ref_str == tag
    assert new_ref_str == tag + dirty_suffix


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

# Path: shipwright/_lib/source_control.py
# def source_control(path, namespace, name_map, mode=None):
#     if mode is None:
#         mode = AUTO
#     assert isinstance(mode, Mode)
#     the_mode = mode if mode is not AUTO else get_mode(path)
#     for cls in SourceControl.__subclasses__():
#         if cls.mode is the_mode:
#             return cls(path, namespace, name_map)
# 
# 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


# Path: tests/integration/test_git.py
import pkg_resources
import pytest
from shipwright._lib import source_control
from .utils import commit_untracked, create_repo

    tmp.join('service2/Dockerfile').write('FROM busybox\n')
    assert scm.is_dirty()

    new_refs = _refs(scm.targets())
    new_ref_str = scm.this_ref_str()

    dirty_suffix = '-dirty-f2f0df80ff0f'
    service2_tag = 'g' * 12 + dirty_suffix
    assert new_refs['shipwright/base'] == tag
    assert new_refs['shipwright/shared'] == tag
    assert new_refs['shipwright/service1'] == tag
    assert new_refs['shipwright/service2'] == service2_tag

    assert new_refs == {
        'shipwright/base': tag,
        'shipwright/service1': tag,
        'shipwright/shared': tag,
        'shipwright/service2': service2_tag,
    }
    assert old_ref_str == tag
    assert new_ref_str == tag + dirty_suffix


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

    repo = create_repo(path, source)