Skip to content

Commit

Permalink
BigInteger support for epoch, major, minor and patch parts of the Pyt…
Browse files Browse the repository at this point in the history
…hon-native package versions (#137)
  • Loading branch information
pilosus authored Mar 15, 2023
1 parent 11d9a22 commit 06a2774
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ This change log follows the conventions of [keepachangelog.com](http://keepachan

## [Unreleased]

## [0.46.0] - 2023-03-15

### Fixed
- Address the bug with supporting `BigInteger` in epoch, major, minor,
and patch parts of the Python-native package versions
([#136](https://github.com/pilosus/pip-license-checker/issues/136))

## [0.45.0] - 2023-03-11

Release **breaks backward compatibility** by adding mandatory `Misc`
Expand Down Expand Up @@ -436,7 +443,8 @@ weak copyleft types.
### Added
- Structure for Leiningen app project

[Unreleased]: https://github.com/pilosus/pip-license-checker/compare/0.45.0...HEAD
[Unreleased]: https://github.com/pilosus/pip-license-checker/compare/0.46.0...HEAD
[0.46.0]: https://github.com/pilosus/pip-license-checker/compare/0.45.0...0.46.0
[0.45.0]: https://github.com/pilosus/pip-license-checker/compare/0.44.0...0.45.0
[0.44.0]: https://github.com/pilosus/pip-license-checker/compare/0.43.0...0.44.0
[0.43.0]: https://github.com/pilosus/pip-license-checker/compare/0.42.1...0.43.0
Expand Down
16 changes: 13 additions & 3 deletions src/pip_license_checker/version.clj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@
0
(read-string number)))

(defn parse-number!
"Parse number string, throw NumberFormatException if parsing fails"
[number]
(cond
(not number)
(throw (IllegalArgumentException. "Wrong argument type"))
(not (re-find #"^[0-9]+$" number))
(throw (NumberFormatException. (format "For input string: \"%s\"" number)))
:else (read-string number)))

(s/fdef parse-letter-version
:args (s/cat :letter ::sp/matched-version-part
:number ::sp/matched-version-part)
Expand Down Expand Up @@ -156,7 +166,7 @@
parsed
(vec (map
#(try
(Integer/parseInt %)
(parse-number! %)
(catch NumberFormatException _ %))
splitted))]
(if (= parsed []) nil parsed)))
Expand All @@ -175,8 +185,8 @@
meta]} version-map
result
{:orig orig
:epoch (if epoch (Integer/parseInt epoch) 0)
:release (vec (map #(Integer/parseInt %) (str/split release #"\.")))
:epoch (if epoch (parse-number! epoch) 0)
:release (vec (map #(parse-number! %) (str/split release #"\.")))
:pre (parse-letter-version prel pren)
:post (parse-letter-version postl (or postn1 postn2))
:dev (parse-letter-version devl devn)
Expand Down
8 changes: 4 additions & 4 deletions test/pip_license_checker/version_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@
:local nil
:meta nil}
"Release, pre, post and dev version"]
["1.0.dev20160909030348"
{:orig "1.0.dev20160909030348"
:epoch 0
:release [1 0]
["20230213094415!20230213094415.20230213094415.20230213094415.dev20160909030348"
{:orig "20230213094415!20230213094415.20230213094415.20230213094415.dev20160909030348"
:epoch 20230213094415
:release [20230213094415 20230213094415 20230213094415]
:pre nil
:post nil
:dev ["dev" 20160909030348]
Expand Down

0 comments on commit 06a2774

Please sign in to comment.