-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.sh
executable file
·35 lines (30 loc) · 931 Bytes
/
sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
set -euo pipefail
Sync__sat_semver.py() {
URL=https://raw.githubusercontent.com/rbarrois/python-semanticversion/master/semantic_version/base.py
script=$1; shift
{
echo '# -*- coding: utf-8 -*-'
echo 'from __future__ import print_function'
echo 'import sys'
echo
} >"$script"
curl -#fSL "$URL" >>"$script"
{
echo
# TODO: only_version doesn't account for semver rc/pre/alpha
echo "only_version = re.compile(r'([0-9]+(\.[0-9]+)+)')" # TODO: use version_re from ^
echo 'constraint = sys.argv[1]'
echo 'refs = {}'
echo 'for ref in sys.argv[2:]:'
echo ' version = only_version.findall(ref)'
echo ' if not version:'
echo ' continue'
echo ' refs[Version.coerce(version[0][0])] = ref'
echo 'selected = SimpleSpec(constraint).select(refs)'
echo 'if not selected:'
echo ' exit(42)'
echo 'print(refs[selected])'
} >>"$script"
}
Sync__sat_semver.py ./sat_semver.py