# 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
from __future__ import absolute_import





def test_default_tags_works_with_detached_head(tmpdir):
    tmp = tmpdir.join('shipwright-sample')
    path = str(tmp)
    source = pkg_resources.resource_filename(
        __name__,
        'examples/shipwright-sample',
    )
    repo = create_repo(path, source)
    old_commit = repo.head.ref.commit
    tmp.join('service1/base.txt').write('Hi mum')
    commit_untracked(repo)

    repo.head.reference = old_commit


# 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

from __future__ import absolute_import





def test_default_tags_works_with_detached_head(tmpdir):
    tmp = tmpdir.join('shipwright-sample')
    path = str(tmp)
    source = pkg_resources.resource_filename(
        __name__,
        'examples/shipwright-sample',
    )
    repo = create_repo(path, source)
    old_commit = repo.head.ref.commit
    tmp.join('service1/base.txt').write('Hi mum')
    commit_untracked(repo)

    repo.head.reference = old_commit


    scm = source_control.GitSourceControl(