예제 #1
0
def add_committer(initials: str,
                  name: str,
                  email: str,
                  *,
                  file_path: Path = _GLOBAL) -> None:
    all_committers = _read_all_committers_from_file(file_path)
    _add_committer_to_committers(all_committers, initials, name, email)
    write_lines(file_path, all_committers)
예제 #2
0
파일: git.py 프로젝트: chiptopher/guet
 def author(self, new_author: Author):
     new_lines = list(self._config_lines)
     user, email = get_author_lines(self._config_lines)
     if user is not None and email is not None:
         overwrite_current_author(new_lines, new_author)
     else:
         append_new_author(new_lines, new_author)
     write_lines(self.path_to_git_folder.joinpath('config'), new_lines)
     self._author = new_author
예제 #3
0
def set_current_committers(committers: List[Committer],
                           project_path: Path) -> None:
    path = Path(join(CONFIGURATION_DIRECTORY, constants.COMMITTERS_SET))
    current_set = all_committers_set()
    new_committers_set = _format_committers_to_committers_set_format(
        committers, project_path)
    _add_to_current_set_lines(current_set, new_committers_set)
    write_lines(
        path,
        [_convert_to_text(committers_set) for committers_set in current_set])
예제 #4
0
파일: hook.py 프로젝트: chiptopher/guet
 def save(self):
     write_lines(self.path, self.content)
     status = stat(str(self.path))
     chmod(str(self.path), status.st_mode | 0o111)
예제 #5
0
def set_errors(error_lines: List[str]):
    write_lines(Path(join(CONFIGURATION_DIRECTORY, constants.ERRORS)),
                error_lines)
예제 #6
0
 def test_writes_lines_to_file(self):
     path: Path = Mock()
     write_lines(path, ['Line1\n', 'Line2\n'])
     path.write_text.assert_called_with('Line1\nLine2\n')
예제 #7
0
 def test_appends_newline_to_files_if_one_is_not_present(self):
     path: Path = Mock()
     given = ['Line1', 'Line2\n']
     write_lines(path, given)
     path.write_text.assert_called_with('Line1\nLine2\n')
예제 #8
0
파일: git.py 프로젝트: chiptopher/guet
 def commit_msg(self, lines: List[str]):
     write_lines(self.path_to_git_folder.joinpath('COMMIT_EDITMSG'), lines)
     self._commit_msg = lines
예제 #9
0
def set_settings(settings: Settings) -> None:
    lines = settings.write()
    write_lines(Path(join(CONFIGURATION_DIRECTORY, constants.CONFIG)), lines)
예제 #10
0
 def save(self):
     if self._marked_for_deletion:
         remove(self._absolute_path)
     elif self._content is not None and self._written_to:
         write_lines(self._absolute_path, self._content)