Skip to content

Add deleteReference #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GitHub/Data/GitData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ instance Binary NewGitReference
data GitReference = GitReference
{ gitReferenceObject :: !GitObject
, gitReferenceUrl :: !URL
, gitReferenceRef :: !Text
, gitReferenceRef :: !(Name GitReference)
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)

Expand Down
13 changes: 13 additions & 0 deletions src/GitHub/Endpoints/GitData/References.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module GitHub.Endpoints.GitData.References (
referencesR,
createReference,
createReferenceR,
deleteReference,
deleteReferenceR,
namespacedReferences,
module GitHub.Data,
) where
Expand Down Expand Up @@ -73,6 +75,17 @@ createReferenceR :: Name Owner -> Name Repo -> NewGitReference -> Request 'RW Gi
createReferenceR user repo newRef =
command Post ["repos", toPathPart user, toPathPart repo , "git", "refs"] (encode newRef)

-- | Delete a reference.
deleteReference :: Auth -> Name Owner -> Name Repo -> Name GitReference -> IO (Either Error ())
deleteReference auth user repo ref =
executeRequest auth $ deleteReferenceR user repo ref

-- | Delete a reference.
-- See <https://developer.github.com/v3/git/refs/#delete-a-reference>
deleteReferenceR :: Name Owner -> Name Repo -> Name GitReference -> GenRequest 'MtUnit 'RW ()
deleteReferenceR user repo ref =
Command Delete ["repos", toPathPart user, toPathPart repo , "git", "refs", toPathPart ref] mempty

-- | Limited references by a namespace.
--
-- > namespacedReferences "thoughtbot" "paperclip" "tags"
Expand Down