コード例 #1
0
ファイル: _remove_local.py プロジェクト: chiptopher/guet
 def execute(self, args: List[str]):
     for hook in all_guet_hooks(self.file_system):
         hook.delete()
     if isdir(project_root().joinpath('.guet')):
         rmtree(project_root().joinpath('.guet'))
         print('guet tracking removed from this repository')
     else:
         print('No local guet configurations for this project')
コード例 #2
0
ファイル: _local_swap.py プロジェクト: chiptopher/guet
 def prepare(self, args: List[str]):
     try:
         local_guet_directory = project_root().joinpath('.guet')
         if isdir(local_guet_directory):
             self.committers.to_local()
     except FileNotFoundError:
         pass
コード例 #3
0
 def prepare(self, args: List[str]):
     if '--local' in args:
         self.committers.to_local()
         config_dir = Path(project_root()).joinpath('.guet')
         if not isdir(config_dir):
             mkdir(config_dir)
             self._create_empty_file(config_dir.joinpath('committers'))
             self._file_system.save_all()
コード例 #4
0
ファイル: _all_guet_hooks.py プロジェクト: chiptopher/guet
def all_guet_hooks(file_system: FileSystem) -> List[File]:
    git_hooks_path = project_root().joinpath('.git').joinpath('hooks')
    found = []
    for file_name in _FILE_NAMES:
        file = file_system.get(git_hooks_path.joinpath(file_name))
        if _is_guet_file(file.read()):
            found.append(file)

    return found
コード例 #5
0
 def _get_committers_file(self) -> File:
     comitters_file_patah = project_root().joinpath('.guet').joinpath(
         COMMITTERS)
     return self.file_system.get(comitters_file_patah)
コード例 #6
0
ファイル: _run.py プロジェクト: chiptopher/guet
from typing import Union

from guet.committers import Committers2 as Committers
from guet.committers import CurrentCommitters
from guet.files import FileSystem
from guet.git import Git
from guet.steps import Step
from guet.util import project_root

from ._commit_msg import CommitMsg
from ._post_commit import PostCommit
from ._pre_commit import PreCommit

FILE_SYSTEM = FileSystem()
COMMITTERS = Committers(FILE_SYSTEM)
GIT = Git(project_root().joinpath('.git'))
CURRENT_COMMITTERS = CurrentCommitters(FILE_SYSTEM, COMMITTERS)
CURRENT_COMMITTERS.register_observer(GIT)


def run(hook: str):
    command = _choose_command(hook)
    if command:
        command.play([])
    FILE_SYSTEM.save_all()


def _choose_command(hook: str) -> Union[Step, None]:
    if hook.endswith('pre-commit'):
        return PreCommit(CURRENT_COMMITTERS)
    elif hook.endswith('post-commit'):
コード例 #7
0
ファイル: test_project_root.py プロジェクト: chiptopher/guet
 def test_finds_folder_with_git_from_given_directory(
         self, mock_recursive_directory_find, mock_getcwd):
     result = project_root()
     self.assertEqual(result, mock_recursive_directory_find.return_value)
     mock_recursive_directory_find.assert_called_with(
         Path(mock_getcwd.return_value), '.git')
コード例 #8
0
 def loader(self):
     return Git(project_root().joinpath('.git'))