# 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('shared/base.txt').write('Hi mum')  # Untracked
    assert scm.is_dirty()

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

    assert new_refs['shipwright/base'] == old_refs['shipwright/base']
    assert new_refs['shipwright/shared'] != old_refs['shipwright/shared']
    assert new_refs['shipwright/service1'] != old_refs['shipwright/service1']

    dirty_tag = tag + '-dirty-adc37b7d003f'
    assert new_refs == {
        'shipwright/base': tag,
        'shipwright/service1': dirty_tag,
        'shipwright/shared': dirty_tag,
    }
    assert old_ref_str == tag
    assert new_ref_str == dirty_tag


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


# 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('shared/base.txt').write('Hi mum')  # Untracked
    assert scm.is_dirty()

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

    assert new_refs['shipwright/base'] == old_refs['shipwright/base']
    assert new_refs['shipwright/shared'] != old_refs['shipwright/shared']
    assert new_refs['shipwright/service1'] != old_refs['shipwright/service1']

    dirty_tag = tag + '-dirty-adc37b7d003f'
    assert new_refs == {
        'shipwright/base': tag,
        'shipwright/service1': dirty_tag,
        'shipwright/shared': dirty_tag,
    }
    assert old_ref_str == tag
    assert new_ref_str == dirty_tag


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


    scm = source_control.GitSourceControl(