예제 #1
0
 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
 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
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
 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'))