Skip to content

Commit 8f62ed5

Browse files
committed
Ability to create an issue
(cherry picked from commit 7d24bba)
1 parent 7cb46f1 commit 8f62ed5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Git.hub/Repository.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,28 @@ public PullRequest CreatePullRequest(string headBranch, string baseBranch, strin
157157
return pullrequest;
158158
}
159159

160+
public Issue CreateIssue(string title, string body)
161+
{
162+
var request = new RestRequest("/repos/{owner}/{repo}/issues");
163+
request.AddUrlSegment("owner", Owner.Login);
164+
request.AddUrlSegment("repo", Name);
165+
166+
request.RequestFormat = DataFormat.Json;
167+
request.AddBody(new
168+
{
169+
title = title,
170+
body = body
171+
});
172+
173+
var issue = _client.Post<Issue>(request).Data;
174+
if (issue == null)
175+
return null;
176+
177+
issue._client = _client;
178+
issue.Repository = this;
179+
return issue;
180+
}
181+
160182
public override bool Equals(object obj)
161183
{
162184
return obj is Repository && GetHashCode() == obj.GetHashCode();

0 commit comments

Comments
 (0)