Skip to content

Commit

Permalink
Fix get-content bug (#33)
Browse files Browse the repository at this point in the history
* Fix get-content bug

Don't try to base64 decode when content is nil.

* Version 0.7.1
  • Loading branch information
marcobiscaro2112 authored Dec 9, 2024
1 parent 8f1dba8 commit d9a4e29
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.7.1

- Fix decoding bug introduced in 0.7.0
- Don't try to base64 decode content if nil

## 0.7.0

- Fix decoding bug in `get-content!`
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject dev.nubank/clj-github "0.7.0"
(defproject dev.nubank/clj-github "0.7.1"
: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 Down
6 changes: 4 additions & 2 deletions src/clj_github/repository.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
([client org repo path]
(get-content! client org repo path {}))
([client org repo path {:keys [ref branch]}]
(base64-lines->string (get-content* client org repo path ref branch))))
(some-> (get-content* client org repo path ref branch)
base64-lines->string)))

(defn get-content-raw!
"Returns the bytes contents of a file from the repository default branch (usually `master`).
Expand All @@ -71,7 +72,8 @@
(^bytes [client org repo path]
(get-content-raw! client org repo path {}))
(^bytes [client org repo path {:keys [ref branch]}]
(base64-lines->bytes (get-content* client org repo path ref branch))))
(some-> (get-content* client org repo path ref branch)
base64-lines->bytes)))

(defn get-repo!
[client org repo]
Expand Down
11 changes: 10 additions & 1 deletion test/clj_github/changeset_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,13 @@
(sut/create-branch! "master"))
(is (nil? (-> (sut/from-branch! client "nubank" "repo" "master")
(sut/delete "file")
(sut/get-content "file")))))))
(sut/get-content "file"))))))
(testing "get missing file"
(with-client [client initial-state]
(-> (sut/orphan client "nubank" "repo")
(sut/put-content "file" "content")
(sut/commit! "initial commit")
(sut/create-branch! "master"))
(let [revision (sut/from-branch! client "nubank" "repo" "master")]
(is (nil? (sut/get-content revision "different_file")))
(is (nil? (sut/get-content-raw revision "different_file")))))))

0 comments on commit d9a4e29

Please sign in to comment.