Skip to content

Commit a645c17

Browse files
committed
Filter daily build versions.
Daily builds available through Chocolatey (e.g. 3.6.8.20200110) were not filtered and considered as stables. Versions are now matched against a regular expression which only accepts versions like `x.y.z`. Then they are compared to the specifier. Fix #9.
1 parent fbea2b0 commit a645c17

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning].
1010
- Travis CI shared configuration snippet intented to be sourced in user
1111
configuration (`dev.yml`).
1212

13+
### Fixed
14+
- Filtering of daily build (available through Chocolatey) (#9).
15+
1316
## [0.1.2] - 2020-01-13
1417
### Fixed
1518
- Recommended way of sourcing the `travis-python.bash` script (#2).

spec/units/versions_spec.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ Describe "__latest_matching_version()"
4444
End
4545

4646
It "filters release candidates"
47-
When call __latest_matching_version "3.7" "3.7.6" "3.7.6rc1" "3.7.6rc2"
47+
When call __latest_matching_version "3.7" "3.7.6" "3.7.6rc2"
4848
The output should equal "3.7.6"
4949
End
5050

51-
It "filters sources versions"
52-
When call __latest_matching_version "pypy-5.7" "pypy-5.7.1" "pypy-5.7.1-src"
53-
The output should equal "pypy-5.7.1"
51+
It "filters daily builds"
52+
When call __latest_matching_version "3.7" "3.7.6" "3.7.6.20200125"
53+
The output should equal "3.7.6"
5454
End
5555

5656
Parameters

travis-python.bash

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ __windows_path() {
8080

8181
if [[ $converted == \\* ]]; then
8282
# If it is an absolute path, convert the first component to a drive letter
83-
drive_letter=$(tr '[:lower:]' '[:upper:]' <<<"${converted:1:1}" )
83+
drive_letter=$(tr '[:lower:]' '[:upper:]' <<<"${converted:1:1}")
8484
converted="$drive_letter:${converted:2}"
8585
fi
8686

@@ -96,7 +96,7 @@ __latest_matching_version() {
9696
# specifier can be a complete version (major.minor.patch) or omit one or
9797
# more leading components.
9898
#
99-
# Only stable versions are considered ()
99+
# Only stable versions are considered.
100100
#
101101
local -r specifier=${1:?the specifier must be specified}
102102
local -r specifier_pattern=${specifier//./"\."}
@@ -116,12 +116,15 @@ __latest_matching_version() {
116116
shopt -s extglob
117117

118118
for version in "${versions[@]}"; do
119-
if [[ $version =~ ^${specifier_pattern}(\.[[:digit:]]+)*$ ]]; then
119+
if [[ $version =~ ^[[:digit:]]+(\.[[:digit:]]+){2}$ && \
120+
$version =~ ^${specifier_pattern} ]]; then
120121
found_version="$version"
121122
fi
122123
done
123124

124-
[[ -n $found_version ]] || return
125+
if [[ -z $found_version ]]; then
126+
return 1
127+
fi
125128

126129
echo "$found_version"
127130
}

0 commit comments

Comments
 (0)