def issue_2(): issue = Issue() issue.id = "ISSUE-2" issue.uuid = 219614693126630377445621689697662132760 issue.date = "2018-02-25T22:33:56.97968" issue.assignee = GitUser("liam", "*****@*****.**") issue.reporter = GitUser("bob", "*****@*****.**") issue.description = "description-of-issue-2" issue.summary = "summary-of-issue-2" return issue
def issue_1(): issue = Issue() issue.id = "ISSUE-1" issue.date = "2018-02-25T22:33:50.04040" issue.uuid = 125118048431737826035520921347116368363 issue.assignee = GitUser("liam", "*****@*****.**") issue.reporter = GitUser("bob", "*****@*****.**") issue.description = "description-of-issue-1" issue.summary = "summary-of-issue-1" return issue
def edit_issue_form(id): form = EditForm(request.form) if form.validate(): issue = Issue() issue.id = id issue.summary = form.summary.data issue.description = form.description.data issue.reporter = GitUser( form.reporter.data) if form.reporter.data != "" else None issue.assignee = GitUser( form.assignee.data) if form.assignee.data != "" else None issue.status = form.status.data user = GitUser() if (form.subscribed.data): matches = [ sub for sub in issue.subscribers if sub.email == user.email ] if (len(matches) == 0): issue.subscribers.append(user) else: issue.subscribers = [ sub for sub in issue.subscribers if sub.email != user.email() ] issue = handler.store_issue(issue, "edit") return render_template("single_issue.html", issue=issue) issue = handler.get_issue(id) if issue is None: return render_template("error_page.html", error_msg=f"Issue {id} not found.") form.summary.data = issue.summary form.description.data = issue.description form.status.data = issue.status form.subscribed.data = False # This needs changed to check if git user is subscribed if (issue.reporter is not None): form.reporter.data = issue.reporter.email if (issue.assignee is not None): form.assignee.data = issue.assignee.email return render_template("edit_issue.html", form=form, issue=issue)
def regular_issue(tracker): issue = Issue() issue.id = "ISSUE-30" issue.assignee = "liam" issue.reporter = "bob" issue.description = "description" issue.summary = "summary" return issue
def issue_3(): issue = Issue() issue.id = "ISSUE-3" issue.uuid = 53368803138698180295652887974160049016 issue.date = "2018-02-25T22:33:58.00000" issue.description = "description-of-issue-3" issue.summary = "summary-of-issue-3" return issue
def post(self): json = request.get_json() issue = Issue() issue.summary = json.get("summary") issue.description = json.get("description") reporter = json.get("reporter") assignee = json.get("assignee") issue.reporter = GitUser(email=reporter.get( "email")) if reporter is not None else GitUser() issue.assignee = GitUser( email=assignee.get("email")) if assignee is not None else None issue.subscribers.append(issue.reporter) if issue.assignee is not None and issue.assignee not in issue.subscribers: issue.subscribers.append(issue.assignee) gm = GitManager() handler = gm.perform_git_workflow(lambda: IssueHandler()) created_issue = handler.store_issue(issue, "create", generate_id=True, store_tracker=True) result = to_payload(GitUser(), issue, IssueSchema) return result.data, HTTPStatus.CREATED, { 'location': f'issues/${created_issue.id}' }
def _get_edit_resolution(self, diverged: Issue, current: Issue) -> Issue: print( f"Issue with ID {diverged.id} and UUID {diverged.uuid} has been changed to {current.id} in a previous " f"merge conflict resolution.") print( "Please examine the two issues and give a resolution to the conflicts when prompted" ) print("\nHEAD:-") current.display() print("\nMERGE HEAD:-") diverged.display() updated_issue = deepcopy(current) diverged.id = current.id fields = self._get_edited_fields(diverged, current) for field, div, curr in fields: edit = input(f"Resolution for {field}:") setattr(updated_issue, field, edit) return updated_issue
def test_get_all_issues(monkeypatch, tmpdir, regular_issue, test_repo): expected = [regular_issue, Issue("ISSUE-NA")] dirs = [] tmpdir.mkdir("/issue") root = f"{test_repo.working_dir}/issue" dirs.append(create_tmp_file(root, expected[0])) dirs.append(create_tmp_file(root, expected[1])) print(dirs) result = handler.get_all_issues() expected.sort(key=lambda x: x.id) result.sort(key=lambda x: x.id) assert len(expected) == len(result) assert expected[0].id == result[0].id and expected[1].id == result[1].id
def test_create_resolver(issue_1: Issue, issue_2: Issue, monkeypatch, first_repo: git.Repo): issue_2.id = "ISSUE-1" # Cause a conflict with the ID's issues = [ConflictInfo("Fake_Path", [issue_1, issue_2])] os.chdir(first_repo.working_dir) monkeypatch.setattr("git_issue.git_manager.GitManager.get_choice_from_user", lambda x, y: True) resolver = CreateConflictResolver() resolver.conflicts = issues resolution = resolver.generate_resolution() found = False for issue in resolution.resolved_issues: if issue.id == "ISSUE-2": found = True assert found
def create(args): issue = Issue() issue.summary = args.summary issue.description = args.description issue.assignee = GitUser(email=args.assignee) if args.assignee != None else None issue.reporter = GitUser(email=args.reporter) issue.subscribers.append(GitUser()) def operation(): handler = GitManager().perform_git_workflow(lambda: IssueHandler()) new_issue = handler.store_issue(issue, "creation", True, True) print(f"ID of newly created issue: {new_issue.id}") confirm_operation(issue, operation)
def create_issue_form(): form = CreateForm(request.form) if form.validate(): issue = Issue() issue.summary = form.summary.data issue.description = form.description.data issue.reporter = GitUser( form.reporter.data) if form.reporter.data != "" else GitUser() issue.assignee = GitUser( form.assignee.data) if form.assignee.data != "" else None issue = handler.store_issue(issue, "edit", generate_id=True) return render_template("single_issue.html", issue=issue) return render_template("create_issue.html", form=form)
def make_issue(self, data): return Issue(**data)
def test_unmerged_conflicts(issue_1: Issue, issue_2: Issue, issue_3: Issue, first_repo: git.Repo, second_repo: git.Repo, monkeypatch): # Create, Create-Edit-Divergence, Comment-Index, Manual issue_2_json = JsonConvert.ToJSON(issue_2) issue_2_copy = JsonConvert.FromJSON(issue_2_json) issue_2_copy.summary = "Edited Summary" monkeypatch.setattr("git_issue.git_manager.GitManager.get_choice_from_user", lambda x, y: True) monkeypatch.setattr("builtins.input", lambda x: 'Y') def merge(repo): try: repo.git.checkout("issue") repo.git.pull("--allow-unrelated-histories", "other", GitManager.ISSUE_BRANCH) except: pass merger = GitMerge(repo) return merger.parse_unmerged_conflicts() # Set up first repo for Create conflict os.chdir(first_repo.working_dir) handler = IssueHandler() handler.store_issue(issue_2, "test", generate_id=True) # Set up second repo for Create conflict os.chdir(second_repo.working_dir) handler = IssueHandler() handler.store_issue(issue_1, "test", generate_id=True) result = merge(second_repo) expected = [ConflictInfo("ISSUE-1/issue.json", [issue_1, issue_2])] assert expected == result GitSynchronizer().merge(GitMerge(second_repo)) # Set up first repo for divergence conflict os.chdir(first_repo.working_dir) handler = IssueHandler() issue_2_copy.id = issue_1.id handler.store_issue(issue_2_copy, "test") os.chdir(second_repo.working_dir) result = merge(second_repo) expected = [ConflictInfo("ISSUE-1/issue.json", [issue_2, issue_1, issue_2_copy])] assert expected == result GitSynchronizer().merge(GitMerge(second_repo)) # Comment os.chdir(first_repo.working_dir) handler = IssueHandler() comment_handler = CommentHandler(handler.get_issue_path(issue_1), issue_1.id) first_comment = Comment("first repo") first_entry = comment_handler.add_comment(first_comment) # Comment os.chdir(second_repo.working_dir) handler = IssueHandler() comment_handler = CommentHandler(handler.get_issue_path(issue_1), issue_1.id) second_comment = Comment("second repo") second_entry = comment_handler.add_comment(second_comment) result = merge(second_repo) expected = [ConflictInfo("ISSUE-1/index.json", [Index([second_entry]), Index([first_entry])])] assert expected == result GitSynchronizer().merge(GitMerge(second_repo)) # Edit conflict issue_1.id = "ISSUE-10" # Just so we don't need to work out the ID issue_1_json = JsonConvert.ToJSON(issue_1) issue_1_first_repo = JsonConvert.FromJSON(issue_1_json) issue_1_second_repo = JsonConvert.FromJSON(issue_1_json) issue_1_first_repo.summary = "First Repo" issue_1_second_repo.summary = "Second Repo" # Set up both repos with the issue that will be used as a conflict os.chdir(first_repo.working_dir) handler = IssueHandler() handler.store_issue(issue_1, "test") os.chdir(second_repo.working_dir) result = merge(second_repo) # Edit first repo os.chdir(first_repo.working_dir) handler.store_issue(issue_1_first_repo, "test") # Edit second repo os.chdir(second_repo.working_dir) handler = IssueHandler() handler.store_issue(issue_1_second_repo, "issue 10 edit") result = merge(second_repo) expected = [ConflictInfo("ISSUE-10/issue.json", [issue_1, issue_1_second_repo, issue_1_first_repo])] assert expected == result GitSynchronizer().merge(GitMerge(second_repo))