Support for Status and Deployment APIs #50

Merged
merged 4 commits into from Nov 12, 2014

Projects

None yet

2 participants

@Raynes Raynes commented on an outdated diff May 22, 2014
src/tentacles/repos.clj
@@ -464,3 +464,77 @@
(if (= (resp :status) 302)
(get-in resp [:headers "location"])
resp))))
+
+;; ## Status API
+(def combined-state-opt-in "application/vnd.github.she-hulk-preview+json")
+
+(defn statuses
+ "Returns the combined status of a ref (SHA, branch, or tag).
+
+By default, returns the combined status. Include `:combined? false' in options to disable combined status (see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref)"
+ [user repo ref & [options]]
+ {:pre [user repo ref]}
@Raynes
Raynes May 22, 2014 owner

I'd prefer to not use pre conditions. None of tentacles uses them, and they don't really seem to make sense here.

@Raynes Raynes commented on an outdated diff May 22, 2014
src/tentacles/repos.clj
@@ -464,3 +464,77 @@
(if (= (resp :status) 302)
(get-in resp [:headers "location"])
resp))))
+
+;; ## Status API
+(def combined-state-opt-in "application/vnd.github.she-hulk-preview+json")
+
+(defn statuses
+ "Returns the combined status of a ref (SHA, branch, or tag).
+
+By default, returns the combined status. Include `:combined? false' in options to disable combined status (see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref)"
@Raynes
Raynes May 22, 2014 owner

Let's try to keep docstrings to within 80 columns. I'm not strict on this (for example, there is a URI in this docstring that will break this rule) but we can definitely be more stringent here. Try to follow the other docstrings in tentacles. Can't say they're perfectly consistent, but they're rarely very wide.

@Raynes Raynes commented on an outdated diff May 22, 2014
src/tentacles/repos.clj
+;; ## Status API
+(def combined-state-opt-in "application/vnd.github.she-hulk-preview+json")
+
+(defn statuses
+ "Returns the combined status of a ref (SHA, branch, or tag).
+
+By default, returns the combined status. Include `:combined? false' in options to disable combined status (see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref)"
+ [user repo ref & [options]]
+ {:pre [user repo ref]}
+ (let [combined? (:combined? options true)]
+ (api-call :get
+ (if combined?
+ "repos/%s/%s/commits/%s/status"
+ "repos/%s/%s/statuses/%s")
+ [user repo ref]
+ (cond->
@Raynes
Raynes May 22, 2014 owner

The formatting of this code is kinda weird. There is a random newline in here that I'd rather go away. I'd like to see something more like this:

(defn statuses
  "Returns the combined status of a ref (SHA, branch, or tag).
   By default, returns the combined status. Include `:combined? false'
   in options to disable combined status
   (see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref)"
  [user repo ref & [options]]
  {:pre [user repo ref]}
  (let [combined? (:combined? options true)]
    (api-call :get
              (if combined?
                "repos/%s/%s/commits/%s/status"
                "repos/%s/%s/statuses/%s")
              [user repo ref]
              (cond-> options
                      combined?
                      (assoc :accept combined-state-opt-in)))))
@vgeshel
vgeshel commented Nov 12, 2014

@Raynes Sorry I've let this go silent for so long, just pushed the changes you asked for.

@Raynes Raynes merged commit 4115915 into Raynes:master Nov 12, 2014
@Raynes
Owner
Raynes commented Nov 12, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment