public void GetCommitComments(string owner, string repo, string username, string password) { GithubApiGateway client = new GithubApiGateway { RequestFilter = GetAuthorizationFilter(username, password), }; // load comments List<GithubCommitComment> comments = DataSerializer<List<GithubCommitComment>>.LoadData(CommitCommentsFile); // load hashes HashSet<string> hashes = LoadHashes(); // pagination for (int i = 1;; ++i) { // add all comments List<GithubCommitComment> tempComments = client.GetRepoComments(owner, repo, i); // reached last page if (tempComments == null || tempComments.Count == 0) { break; } comments.AddRange(tempComments); } // filter comments by commit hashes if (hashes != null) { for (int i = 0; i < comments.Count;) { if (hashes.Contains(comments[i].commit_id)) { ++i; } else { comments.RemoveAt(i); } } } // save comments DataSerializer<List<GithubCommitComment>>.SaveData(comments, CommitCommentsFile); }
public void PostCommitComments(string owner, string repo, string username, string password) { GithubApiGateway client = new GithubApiGateway { RequestFilter = GetAuthorizationFilter(username, password), }; // load comments List<GithubCommitComment> comments = DataSerializer<List<GithubCommitComment>>.LoadData(CommitCommentsFile); // post comments foreach (GithubCommitComment comment in comments) { client.PostRepoCommitComment(ToPostCommitComment(comment), owner, repo, comment.commit_id); } }
public void PostIssues(string owner, string repo, string username, string password) { GithubApiGateway client = new GithubApiGateway { RequestFilter = GetAuthorizationFilter(username, password), }; // load issues List<GithubIssue> issues = DataSerializer<List<GithubIssue>>.LoadData(IssuesFile); // post issues foreach (GithubIssue issue in issues) { GithubIssue issueResponse = client.PostRepoIssue(ToPostIssue(issue), owner, repo).FromJson<GithubIssue>(); issue.Number = issueResponse.Number; } // post comments foreach (GithubIssue issue in issues) { if (issue.CommentContents != null) { foreach (GithubIssueComment comment in issue.CommentContents) { client.PostRepoIssueComment(ToPostIssueComment(comment), owner, repo, issue.Number); } } } }
public void GetIssues(string owner, string repo, string username, string password) { GithubApiGateway client = new GithubApiGateway { RequestFilter = GetAuthorizationFilter(username, password), }; // load issues List<GithubIssue> issues = DataSerializer<List<GithubIssue>>.LoadData(IssuesFile); List<GithubIssue> newIssues = new List<GithubIssue>(); // TODO: Use response header "Links" for proper pagination // pagination for (int i = 1;; ++i) { // add open issues List<GithubIssue> tempIssues = client.GetRepoIssues(owner, repo, i, true, true); // reached last page if (tempIssues == null || tempIssues.Count == 0) { break; } newIssues.AddRange(tempIssues); } // pagination for (int i = 1;; ++i) { // add closed issues List<GithubIssue> tempIssues = client.GetRepoIssues(owner, repo, i, false, true); // reached last page if (tempIssues == null || tempIssues.Count == 0) { break; } newIssues.AddRange(tempIssues); } // sort by id newIssues.Sort(); // add issues and comments to main list foreach (GithubIssue newIssue in newIssues) { // skip pull requests if (newIssue.Pull_Request != null) { if (!string.IsNullOrEmpty(newIssue.Pull_Request.Html_Url)) { continue; } newIssue.Pull_Request = null; } // add comments if (newIssue.Comments > 0) { newIssue.CommentContents = new List<GithubIssueComment>(); // pagination for (int i = 1;; ++i) { List<GithubIssueComment> tempComments = client.GetRepoIssueComments(owner, repo, newIssue.Number, i); // reached last page if (tempComments == null || tempComments.Count == 0) { break; } newIssue.CommentContents.AddRange(tempComments); } } issues.Add(newIssue); } // save issues DataSerializer<List<GithubIssue>>.SaveData(issues, IssuesFile); }