Skip to content

Commit

Permalink
Fix branch name error with special char (#25)
Browse files Browse the repository at this point in the history
* Fix branch name error with special char

Signed-off-by: Lucas Piazzi <lpiazzi26@gmail.com>

* Update src/clj_github/repository.clj

Fix code to address clojure style guide

Co-authored-by: Francine Pilot <francine.pilot@nubank.com.br>

* Add codec to project deps / change form-encode to url-encode

Signed-off-by: Lucas Piazzi <lpiazzi26@gmail.com>

* Fix deps name

Signed-off-by: Lucas Piazzi <lpiazzi26@gmail.com>

* Change form-encode to url-encode in repository.clj

* Update CHANGELOG.MD

Signed-off-by: Lucas Piazzi <lpiazzi26@gmail.com>

* Update project.clj project version

---------

Signed-off-by: Lucas Piazzi <lpiazzi26@gmail.com>
Co-authored-by: Francine Pilot <francine.pilot@nubank.com.br>
  • Loading branch information
Piazzi and franpilot authored Sep 20, 2023
1 parent eab2267 commit 3985011
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.6.3
- Fix special characters on branch name

## 0.6.2
- Bump `clj-github-app` version

Expand Down
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject dev.nubank/clj-github "0.6.2"
(defproject dev.nubank/clj-github "0.6.3"
:description "A Clojure library for interacting with the github developer API"
:url "https://github.com/nubank/clj-github"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand All @@ -19,7 +19,8 @@
[http-kit "2.5.3"]
[nubank/clj-github-app "0.2.1"]
[nubank/state-flow "5.14.0"]
[clj-commons/fs "1.6.310"]]
[clj-commons/fs "1.6.310"]
[ring/ring-codec "1.2.0"]]

:cljfmt {:indents {flow [[:block 1]]
assoc-some [[:block 0]]}}
Expand Down
5 changes: 3 additions & 2 deletions src/clj_github/repository.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[clojure.java.io :as io]
[clojure.string :as string]
[me.raynes.fs :as fs]
[me.raynes.fs.compression :as fs-compression])
[me.raynes.fs.compression :as fs-compression]
[ring.util.codec :as codec])
(:import [clojure.lang ExceptionInfo]
[java.util Base64]))

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

(defn get-tree!
"Returns information about a tree.
Expand Down
16 changes: 11 additions & 5 deletions test/clj_github/httpkit_client_test.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(ns clj-github.httpkit-client-test
(:require [clojure.test :refer [deftest is testing]]
[clj-github.httpkit-client :as sut]
[matcher-combinators.clj-test]
[org.httpkit.fake :refer [with-fake-http]]))
(:require
[clojure.test :refer [deftest is testing]]
[clj-github.httpkit-client :as sut]
[matcher-combinators.clj-test]
[org.httpkit.fake :refer [with-fake-http]]
[ring.util.codec :as codec]))

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

0 comments on commit 3985011

Please sign in to comment.