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)
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
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])
def save(self): write_lines(self.path, self.content) status = stat(str(self.path)) chmod(str(self.path), status.st_mode | 0o111)
def set_errors(error_lines: List[str]): write_lines(Path(join(CONFIGURATION_DIRECTORY, constants.ERRORS)), error_lines)
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')
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')
def commit_msg(self, lines: List[str]): write_lines(self.path_to_git_folder.joinpath('COMMIT_EDITMSG'), lines) self._commit_msg = lines
def set_settings(settings: Settings) -> None: lines = settings.write() write_lines(Path(join(CONFIGURATION_DIRECTORY, constants.CONFIG)), lines)
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)