-
Notifications
You must be signed in to change notification settings - Fork 10
1.3. Repositories
Sergey Sobko edited this page Feb 22, 2018
·
1 revision
Repository protocols are very similar to tracker ones. Let's create the definitions from the section above, but this time for our repositories:
(require '[flower.repository.core :as repository.core]
'[flower.repository.proto :as repository.proto])
;; Our repositories definition
(def pt-repos (let [organization-url "https://github.com/PositiveTechnologies"]
(repository.core/repositories (repository.core/start-component {})
{:pt-github {:repo-type :github
:repo-url organization-url
:repo-projects ["flower"]}})))
Here is a shorthand notation to create a single repository record:
(def pt-github-repo (repository.core/get-repository "https://github.com/PositiveTechnologies/flower"))
The repository type is identified by its domain name. If it failed to get identified automatically, use the flower.repository.core/with-repository-type
macro to set the type manually:
(require '[flower.macros :as macros])
(require '[flower.repository.core :as repository.core])
(macros/with-default-credentials
(repository.core/with-repository-type :gitlab
(def gitlab-repo (repository.core/get-repository "https://git.example.com/example/example-project"))))
Let's find out the title and the corresponding source branch for every pull request in our repository:
(map #(list (repository.proto/get-title %)
(repository.proto/get-source-branch %))
(repository.proto/get-pull-requests pt-github-repo))
Let's get list of commits for some opened pull request and then merge it
(make sure you specified :auth
beforehand, see previous section):
(let [first-opened-pr (first (repository.proto/get-pull-requests pt-github-repo
{:pr-state "opened"}))
commits (map :commit-id (repository.proto/get-commits first-opened-pr))]
(println commits)
(repository.proto/merge-pull-request! first-opened-pr))