gitlab-haskell 0.2.4 → 0.2.5
raw patch · 7 files changed
+69/−15 lines, 7 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- GitLab.Types: [humane_time_estimate] :: TimeStats -> Maybe Int
+ GitLab.API.Commits: branchCommits :: Project -> Text -> GitLab (Either Status [Commit])
+ GitLab.API.Commits: branchCommits' :: Int -> Text -> GitLab (Either Status [Commit])
+ GitLab.API.MergeRequests: mergeRequest :: Project -> Int -> GitLab (Either Status (Maybe MergeRequest))
+ GitLab.API.MergeRequests: mergeRequest' :: Int -> Int -> GitLab (Either Status (Maybe MergeRequest))
+ GitLab.Types: [human_time_estimate] :: TimeStats -> Maybe Int
- GitLab.Types: MergeRequest :: Int -> Int -> Int -> Text -> Text -> Text -> Maybe User -> Maybe Text -> Maybe User -> Maybe Text -> Text -> Text -> Text -> Text -> Int -> Int -> User -> Maybe User -> Int -> Int -> [Text] -> Bool -> Maybe Milestone -> Bool -> Text -> Text -> Maybe Text -> Int -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Text -> TimeStats -> Bool -> Maybe Int -> Maybe Pipeline -> Maybe Int -> Maybe Bool -> Bool -> Maybe Bool -> Maybe Bool -> MergeRequest
+ GitLab.Types: MergeRequest :: Int -> Int -> Int -> Text -> Text -> Text -> Maybe User -> Maybe Text -> Maybe User -> Maybe Text -> Text -> Text -> Text -> Text -> Int -> Int -> User -> Maybe User -> Int -> Int -> [Text] -> Bool -> Maybe Milestone -> Bool -> Text -> Text -> Maybe Text -> Int -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Maybe Bool -> Text -> TimeStats -> Bool -> Maybe String -> Maybe Pipeline -> Maybe Int -> Maybe Bool -> Bool -> Maybe Bool -> Maybe Bool -> MergeRequest
- GitLab.Types: [merge_request_changes_count] :: MergeRequest -> Maybe Int
+ GitLab.Types: [merge_request_changes_count] :: MergeRequest -> Maybe String
Files
- README.md +7/−7
- gitlab-haskell.cabal +1/−1
- src/GitLab/API/Commits.hs +26/−0
- src/GitLab/API/Groups.hs +2/−2
- src/GitLab/API/MergeRequests.hs +28/−0
- src/GitLab/API/Projects.hs +1/−1
- src/GitLab/Types.hs +4/−4
README.md view
@@ -17,8 +17,14 @@ * Users The library parses JSON results into Haskell data types in the-`GitLab.Types` module.+`GitLab.Types` module, allowing you to work with statically typed+GitLab data with data types and functions that the library+provides. E.g. + searchUser :: Text -> GitLab (Maybe User)+ userProjects :: User -> GitLab (Maybe [Project])+ projectCommits :: Project -> GitLab [Commit]+ ## Example Run all GitLab actions with `runGitLab`: @@ -36,12 +42,6 @@ { url = "https://gitlab.example.com" , token="my_token"} ) (searchUser "joe" >>= userProjects . fromJust)--Which uses the functions:-- searchUser :: Text -> GitLab (Maybe User)- userProjects :: User -> GitLab (Maybe [Project])- projectCommits :: Project -> GitLab [Commit] This library can also be used to implement rule based GitLab file system hooks that, when deployed a GitLab server, react in real time
gitlab-haskell.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: gitlab-haskell category: Git-version: 0.2.4+version: 0.2.5 synopsis: A Haskell library for the GitLab web API description: This Haskell library queries and updates the database of a GitLab instance using the GitLab web API: <https://docs.gitlab.com/ee/api/>
src/GitLab/API/Commits.hs view
@@ -37,6 +37,32 @@ commitsAddr projId = "/projects/" <> T.pack (show projId) <> "/repository" <> "/commits" +-- | returns all commits of a branch from a project given the branch+-- name.+branchCommits ::+ -- | project+ Project ->+ -- | branch name+ Text ->+ GitLab (Either Status [Commit])+branchCommits project =+ branchCommits' (project_id project)++-- | returns all commits of a branch from a project+-- given its project ID and the branch name.+branchCommits' ::+ -- | project ID+ Int ->+ -- | branch name+ Text ->+ GitLab (Either Status [Commit])+branchCommits' projectId branchName = do+ gitlabWithAttrs (commitsAddr projectId) ("&ref_name=" <> branchName)+ where+ commitsAddr :: Int -> Text+ commitsAddr projId =+ "/projects/" <> T.pack (show projId) <> "/repository" <> "/commits"+ -- | returns a commit for the given project and commit hash, if such -- a commit exists. commitDetails ::
src/GitLab/API/Groups.hs view
@@ -76,7 +76,7 @@ -- | user ID Int -> GitLab (Either Status (Maybe Member))-addUserToGroup' groupName access userId = do+addUserToGroup' groupName access usrId = do attempt <- groupsWithNameOrPath groupName case attempt of Left httpStatus -> return (Left httpStatus)@@ -86,7 +86,7 @@ where dataBody :: Text dataBody =- "user_id=" <> T.pack (show userId) <> "&access_level="+ "user_id=" <> T.pack (show usrId) <> "&access_level=" <> T.pack (show access) addr = "/groups/"
src/GitLab/API/MergeRequests.hs view
@@ -16,6 +16,34 @@ import GitLab.WebRequests.GitLabWebCalls import Network.HTTP.Types.Status +-- | returns the merge request for a project given its merge request+-- IID.+mergeRequest ::+ -- | project+ Project ->+ -- | merge request IID+ Int ->+ GitLab (Either Status (Maybe MergeRequest))+mergeRequest project =+ mergeRequest' (project_id project)++-- | returns the merge request for a project given its project ID and+-- merge request IID.+mergeRequest' ::+ -- | project ID+ Int ->+ -- | merge request IID+ Int ->+ GitLab (Either Status (Maybe MergeRequest))+mergeRequest' projectId mergeRequestIID =+ gitlabOne addr+ where+ addr =+ "/projects/"+ <> T.pack (show projectId)+ <> "/merge_requests/"+ <> T.pack (show mergeRequestIID)+ -- | returns the merge requests for a project. mergeRequests :: -- | the project
src/GitLab/API/Projects.hs view
@@ -116,7 +116,7 @@ Nothing -> return Nothing Just usr -> Just <$> gitlabUnsafe (urlPath (user_id usr)) where- urlPath userId = "/users/" <> T.pack (show userId) <> "/projects"+ urlPath usrId = "/users/" <> T.pack (show usrId) <> "/projects" -- | gets all projects for a user. --
src/GitLab/Types.hs view
@@ -292,7 +292,7 @@ data TimeStats = TimeStats { time_estimate :: Int, total_time_spent :: Int,- humane_time_estimate :: Maybe Int,+ human_time_estimate :: Maybe Int, human_total_time_spent :: Maybe Int } deriving (Generic, Show)@@ -528,7 +528,7 @@ merge_request_web_url :: Text, merge_request_time_stats :: TimeStats, merge_request_squash :: Bool,- merge_request_changes_count :: Maybe Int,+ merge_request_changes_count :: Maybe String, merge_request_pipeline :: Maybe Pipeline, merge_request_diverged_commits_count :: Maybe Int, merge_request_rebase_in_progress :: Maybe Bool,@@ -707,12 +707,12 @@ bodyNoPrefix "repository_name" = "name" bodyNoPrefix "repository_path" = "path" bodyNoPrefix "repository_type" = "type"-bodyNoPrefix "user_avatar_url" = "avatar_url"+bodyNoPrefix "user_avatar_uri" = "avatar_url" bodyNoPrefix "user_id" = "id" bodyNoPrefix "user_name" = "name" bodyNoPrefix "user_state" = "state" bodyNoPrefix "user_username" = "username"-bodyNoPrefix "user_web_url" = "we_url"+bodyNoPrefix "user_web_url" = "web_url" bodyNoPrefix "event_title" = "title" bodyNoPrefix "event_project_id" = "project_id" bodyNoPrefix "pipeline_ref" = "ref"