Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#620 Black on factories and data_interface

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:hotfix/SG-000-black_on_some_common
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  1. #!/usr/bin/env bash
  2. ## Copyright (C) 2017, Oleksandr Kucherenko
  3. ## Last revisit: 2017-09-29
  4. # For help:
  5. # ./versionip.sh --help
  6. # For developer / references:
  7. # https://ryanstutorials.net/bash-scripting-tutorial/bash-functions.php
  8. # http://tldp.org/LDP/abs/html/comparison-ops.html
  9. # https://misc.flogisoft.com/bash/tip_colors_and_formatting
  10. ## display help
  11. function help() {
  12. echo 'usage: ./version-up.sh [-r|--release] [-a|--alpha] [-b|--beta] [-c|--release-candidate]'
  13. echo ' [-m|--major] [-i|--minor] [-p|--patch] [-e|--revision] [-g|--git-revision]'
  14. echo ' [--stay] [--default] [--help]'
  15. echo ''
  16. echo 'Switches:'
  17. echo ' --release switch stage to release, no suffix, -r'
  18. echo ' --alpha switch stage to alpha, -a'
  19. echo ' --beta switch stage to beta, -b'
  20. echo ' --release-candidate switch stage to rc, -c'
  21. echo ' --major increment MAJOR version part, -m'
  22. echo ' --minor increment MINOR version part, -i'
  23. echo ' --patch increment PATCH version part, -p'
  24. echo ''
  25. echo 'Version: MAJOR.MINOR.PATCH'
  26. echo ''
  27. echo 'Reference:'
  28. echo ' http://semver.org/'
  29. echo ''
  30. echo 'Versions priority:'
  31. echo ' 1.0.0-alpha < 1.0.0-beta < 1.0.0-rc < 1.0.0'
  32. exit 0
  33. }
  34. ## parse last found tag, extract it PARTS
  35. function parse_last() {
  36. local position=$(($1 - 1))
  37. # two parts found only
  38. local SUBS=(${PARTS[$position]//-/ })
  39. #echo ${SUBS[@]}, size: ${#SUBS}
  40. # found NUMBER
  41. PARTS[$position]=${SUBS[0]}
  42. #echo ${PARTS[@]}
  43. # found SUFFIX
  44. if [[ ${#SUBS} -ge 1 ]]; then
  45. PARTS[4]=${SUBS[1],,} #lowercase
  46. #echo ${PARTS[@]}, ${SUBS[@]}
  47. fi
  48. }
  49. ## increment PATCH part, reset all other lower PARTS, don't touch STAGE
  50. function increment_patch() {
  51. PARTS[2]=$((PARTS[2] + 1))
  52. PARTS[3]=0
  53. }
  54. ## increment MINOR part, reset all other lower PARTS, don't touch STAGE
  55. function increment_minor() {
  56. PARTS[1]=$((PARTS[1] + 1))
  57. PARTS[2]=0
  58. PARTS[3]=0
  59. }
  60. ## increment MAJOR part, reset all other lower PARTS, don't touch STAGE
  61. function increment_major() {
  62. PARTS[0]=$((PARTS[0] + 1))
  63. PARTS[1]=0
  64. PARTS[2]=0
  65. PARTS[3]=0
  66. }
  67. ## compose version from PARTS
  68. function compose() {
  69. MAJOR="${PARTS[0]}"
  70. MINOR=".${PARTS[1]}"
  71. PATCH=".${PARTS[2]}"
  72. echo "${MAJOR}${MINOR}${PATCH}" #full format
  73. }
  74. # parse input parameters
  75. for i in "$@"; do
  76. key="$i"
  77. case $key in
  78. -v | --version) # tag prefix #fixme: will work only if placed as first argument
  79. VERSION=$2
  80. PARTS=(${VERSION//./ })
  81. parse_last ${#PARTS[@]} # array size as argument
  82. shift 2
  83. ;;
  84. -p | --patch) # increment of PATCH
  85. increment_patch
  86. ;;
  87. -i | --minor) # increment of MINOR by default
  88. increment_minor
  89. ;;
  90. -m | --major) # increment of MAJOR
  91. increment_major
  92. ;;
  93. esac
  94. shift
  95. done
  96. echo -e "$(compose)"
Discard
Tip!

Press p or to see the previous file or, n or to see the next file