Skip to content

Commit 1d1d6e0

Browse files
Thomas M. DuBuissonphadej
authored andcommitted
Commit posisition change
1 parent c2968f3 commit 1d1d6e0

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22

33
## Changes for 0.21
44

5+
- Refactor `Request` type.
6+
[#349](https://github.com/phadej/github/pull/349)
57
- Allow `http-client-0.6`
8+
[#344](https://github.com/phadej/github/pull/344)
69
- Change to use `cryptohash-sha1` (`cryptohash` was used before)
10+
- Add Create milestone endponts
11+
[#337](https://github.com/phadej/github/pull/337)
12+
- Make fileBlobUrl and fileRawUrl are optional
13+
[#339](https://github.com/phadej/github/issues/339)
14+
[#340](https://github.com/phadej/github/pull/340)
15+
- Add organizationsR to request user organizations
16+
[#345](https://github.com/phadej/github/pull/345)
17+
- Add updateMilestoneR, deleteMilestoneR
18+
[#338](https://github.com/phadej/github/pull/338)
19+
- Allow multiple assignees in NewIssue and EditIssue
20+
[#336](https://github.com/phadej/github/pull/336)
721

822
## Changes for 0.20
923

src/GitHub.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ module GitHub (
206206
-- Missing endpoints:
207207
--
208208
-- * List comments in a repository
209-
-- * Create a comment
210209
-- * Edit a comment
211210
-- * Delete a comment
212211
pullRequestCommentsR,
213212
pullRequestCommentR,
213+
createPullCommentR,
214214

215215
-- ** Pull request reviews
216216
-- | See <https://developer.github.com/v3/pulls/reviews/>

src/GitHub/Data/Comments.hs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,22 @@ instance Binary EditComment
6464

6565
instance ToJSON EditComment where
6666
toJSON (EditComment b) = object [ "body" .= b ]
67+
68+
data NewPullComment = NewPullComment
69+
{ newPullCommentCommit :: !Text
70+
, newPullCommentPath :: !Text
71+
, newPullCommentPosition :: !Int
72+
, newPullCommentBody :: !Text
73+
}
74+
deriving (Show, Data, Typeable, Eq, Ord, Generic)
75+
76+
instance NFData NewPullComment where rnf = genericRnf
77+
instance Binary NewPullComment
78+
79+
instance ToJSON NewPullComment where
80+
toJSON (NewPullComment c path pos b) =
81+
object [ "body" .= b
82+
, "commit_id" .= c
83+
, "path" .= path
84+
, "position" .= pos
85+
]

src/GitHub/Endpoints/PullRequests/Comments.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module GitHub.Endpoints.PullRequests.Comments (
1010
pullRequestCommentsR,
1111
pullRequestComment,
1212
pullRequestCommentR,
13+
createPullComment,
14+
createPullCommentR,
1315
module GitHub.Data,
1416
) where
1517

@@ -43,3 +45,21 @@ pullRequestComment user repo cid =
4345
pullRequestCommentR :: Name Owner -> Name Repo -> Id Comment -> Request k Comment
4446
pullRequestCommentR user repo cid =
4547
query ["repos", toPathPart user, toPathPart repo, "pulls", "comments", toPathPart cid] []
48+
49+
-- | Create a new comment.
50+
--
51+
-- > createPullComment (User (user, password)) user repo issue commit path position
52+
-- > "some words"
53+
createPullComment :: Auth -> Name Owner -> Name Repo -> IssueNumber -> Text -> Text -> Int -> Text
54+
-> IO (Either Error Comment)
55+
createPullComment auth user repo iss commit path position body =
56+
executeRequest auth $ createPullCommentR user repo iss commit path position body
57+
58+
-- | Create a comment.
59+
--
60+
-- See <https://developer.github.com/v3/pulls/comments/#create-a-comment>
61+
createPullCommentR :: Name Owner -> Name Repo -> IssueNumber -> Text -> Text -> Int -> Text -> Request 'RW Comment
62+
createPullCommentR user repo iss commit path position body =
63+
command Post parts (encode $ NewPullComment commit path position body)
64+
where
65+
parts = ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart iss, "comments"]

0 commit comments

Comments
 (0)