Skip to content

Commit 3985011

Browse files
Piazzifranpilot
andauthored
Fix branch name error with special char (#25)
* Fix branch name error with special char Signed-off-by: Lucas Piazzi <[email protected]> * Update src/clj_github/repository.clj Fix code to address clojure style guide Co-authored-by: Francine Pilot <[email protected]> * Add codec to project deps / change form-encode to url-encode Signed-off-by: Lucas Piazzi <[email protected]> * Fix deps name Signed-off-by: Lucas Piazzi <[email protected]> * Change form-encode to url-encode in repository.clj * Update CHANGELOG.MD Signed-off-by: Lucas Piazzi <[email protected]> * Update project.clj project version --------- Signed-off-by: Lucas Piazzi <[email protected]> Co-authored-by: Francine Pilot <[email protected]>
1 parent eab2267 commit 3985011

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.6.3
4+
- Fix special characters on branch name
5+
36
## 0.6.2
47
- Bump `clj-github-app` version
58

project.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject dev.nubank/clj-github "0.6.2"
1+
(defproject dev.nubank/clj-github "0.6.3"
22
:description "A Clojure library for interacting with the github developer API"
33
:url "https://github.com/nubank/clj-github"
44
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
@@ -19,7 +19,8 @@
1919
[http-kit "2.5.3"]
2020
[nubank/clj-github-app "0.2.1"]
2121
[nubank/state-flow "5.14.0"]
22-
[clj-commons/fs "1.6.310"]]
22+
[clj-commons/fs "1.6.310"]
23+
[ring/ring-codec "1.2.0"]]
2324

2425
:cljfmt {:indents {flow [[:block 1]]
2526
assoc-some [[:block 0]]}}

src/clj_github/repository.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
[clojure.java.io :as io]
66
[clojure.string :as string]
77
[me.raynes.fs :as fs]
8-
[me.raynes.fs.compression :as fs-compression])
8+
[me.raynes.fs.compression :as fs-compression]
9+
[ring.util.codec :as codec])
910
(:import [clojure.lang ExceptionInfo]
1011
[java.util Base64]))
1112

@@ -74,7 +75,7 @@
7475
Look at https://developer.github.com/v3/repos/branches/#get-a-branch for details about the response format."
7576
[client org repo branch]
7677
(fetch-body! client {:method :get
77-
:path (format "/repos/%s/%s/branches/%s" org repo branch)}))
78+
:path (format "/repos/%s/%s/branches/%s" org repo (codec/url-encode branch))}))
7879

7980
(defn get-tree!
8081
"Returns information about a tree.

test/clj_github/httpkit_client_test.clj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
(ns clj-github.httpkit-client-test
2-
(:require [clojure.test :refer [deftest is testing]]
3-
[clj-github.httpkit-client :as sut]
4-
[matcher-combinators.clj-test]
5-
[org.httpkit.fake :refer [with-fake-http]]))
2+
(:require
3+
[clojure.test :refer [deftest is testing]]
4+
[clj-github.httpkit-client :as sut]
5+
[matcher-combinators.clj-test]
6+
[org.httpkit.fake :refer [with-fake-http]]
7+
[ring.util.codec :as codec]))
68

79
(deftest request-test
810
(let [client (sut/new-client {:token-fn (fn [] "token")})]
@@ -43,4 +45,8 @@
4345
(with-fake-http [{} {:error cause :status nil}]
4446
(let [e (try (sut/request client {}) (catch Exception e e))]
4547
(is (re-matches #"(?i)Request to GitHub failed" (.getMessage e)))
46-
(is (= cause (.getCause e)))))))))
48+
(is (= cause (.getCause e)))))))
49+
(testing "url path contains special character `|`"
50+
(with-fake-http [{:url "https://api.github.com/test%7Ctest"}
51+
{:status 200}]
52+
(is (match? {:status 200} (sut/request client {:path (str "/" (codec/url-encode "test|test"))})))))))

0 commit comments

Comments
 (0)