Skip to content

Commit

Permalink
Merge pull request #253 from fukamachi/fix/github-source-many-branches
Browse files Browse the repository at this point in the history
Fix an error while retrieving the git ref for `github` sources.
  • Loading branch information
fukamachi committed Jul 4, 2024
2 parents 4f06d1b + 7656da0 commit ae3ace1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/distify/github.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,28 @@
(gethash "default_branch" (retrieve-from-github repos)))

(defun retrieve-source-git-ref-from-github (source)
(labels ((find-ref (results name)
(let ((result (find-if (lambda (result)
(string= (gethash "name" result) name))
results)))
(and result
(gethash "sha" (gethash "commit" result)))))
(get-ref (action name)
(find-ref (retrieve-from-github (source-github-repos source) action)
name)))
(labels ((get-tag-ref (name)
(reduce #'gethash
'("sha" "object")
:initial-value
(retrieve-from-github (source-github-repos source)
(format nil "/git/refs/tags/~A" name))
:from-end t))
(get-branch-ref (name)
(reduce #'gethash
'("sha" "commit")
:initial-value
(retrieve-from-github (source-github-repos source)
(format nil "/branches/~A" name))
:from-end t)))
(cond
((source-github-ref source))
((source-github-branch source)
(get-ref "/branches" (source-github-branch source)))
(get-branch-ref (source-github-branch source)))
((source-github-tag source)
(get-ref "/tags" (source-github-tag source)))
(t (get-ref "/branches" (retrieve-default-branch (source-github-repos source)))))))
(get-tag-ref (source-github-tag source)))
(t
(get-branch-ref (retrieve-default-branch (source-github-repos source)))))))

(defun load-source-github-version (source)
(unless (ignore-errors (source-github-ref source))
Expand Down
4 changes: 4 additions & 0 deletions src/http.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
(:shadow #:get)
(:import-from #:qlot/proxy
#:*proxy*)
(:import-from #:qlot/logger
#:*debug*)
(:import-from #:dexador)
#-windows
(:import-from #:cl+ssl)
Expand All @@ -23,6 +25,7 @@
:if-exists :supersede
:keep-alive nil
:proxy *proxy*
:verbose *debug*
(and basic-auth
(list :basic-auth basic-auth)))))

Expand All @@ -32,4 +35,5 @@
(apply #'dex:get url
:keep-alive nil
:proxy *proxy*
:verbose *debug*
args)))

0 comments on commit ae3ace1

Please sign in to comment.