def test_store_issue_has_correct_path(regular_issue, test_repo): root = f"{test_repo.working_dir}/issue" ih = IssueHandler() ih.store_issue(regular_issue, None) gm = GitManager() gm.load_issue_branch() assert Path(f"{root}/{regular_issue.id}/issue.json").exists()
def does_issue_exist(self, id: str): gm = GitManager() is_loaded = gm.is_inside_branch() if not is_loaded: gm.load_issue_branch() exists = _generate_issue_file_path(id).exists() if not is_loaded: gm.unload_issue_branch() return exists
def resolve(self): gm = GitManager() gm.load_issue_branch() paths = [] handler = IssueHandler() for issue in self.resolved_issues: file_path = handler.get_issue_path(issue) JsonConvert.ToFile(issue, file_path) paths.append(str(file_path)) repo = gm.obtain_repo() for path in paths: repo.git.add(path)
def test_repo(tmpdir): repo = git.Repo.init(tmpdir.mkdir("test_repo")) fake_file_dir = Path(repo.working_dir + "/fake-file.pla") open(fake_file_dir, 'w').close() repo.index.add([str(fake_file_dir)]) repo.index.commit("Blah") os.chdir(repo.working_dir) gm = GitManager() setattr(gm, "get_choice_from_user", lambda x: True) gm.load_issue_branch() return repo
def get_issue_from_issue_id(self, id): gm = GitManager() is_loaded = gm.is_inside_branch() if not is_loaded: gm.load_issue_branch() try: file = JsonConvert.FromFile(_generate_issue_file_path(id)) except FileNotFoundError: return None if not is_loaded: gm.unload_issue_branch() return file