def _remove_config(self, rel_path, message): """Remove and commit the removal of an existing config file. :rel_path: the string relative path to the config file :message: the string commit message for the file """ if phlgit_diffindex.is_index_dirty(self._repo): raise Error("git index has staged changes") path = self._make_abspath(rel_path) if not os.path.exists(path): raise Error("config doesn't exist: {}".format(rel_path)) self._repo('rm', rel_path) phlgit_commit.index(self._repo, message)
def _create_config(self, rel_path, content, message): """Create and commit a new config file. :rel_path: the string relative path to the config file :content: the string contents of the new config file :message: the string commit message for the file """ if phlgit_diffindex.is_index_dirty(self._repo): raise Error("git index has staged changes") path = self._make_abspath(rel_path) if os.path.exists(path): raise Error("config already exists") phlsys_fs.write_text_file(path, content) self._repo('add', rel_path) phlgit_commit.index(self._repo, message)