Skip to content

feat: get rid of poetry dependency in version checker#6

Open
OriginalUtkin wants to merge 2 commits intomasterfrom
ku/remove_usage_of_poetry_dependency
Open

feat: get rid of poetry dependency in version checker#6
OriginalUtkin wants to merge 2 commits intomasterfrom
ku/remove_usage_of_poetry_dependency

Conversation

@OriginalUtkin
Copy link
Owner

In previous release poetry dependency was introduced in order to be able check version of poetry file. It was done as quick solution just to make it works.

This merge request removes such dependency in order not to relate on it inside the container it is being run in CI/CD container.

@OriginalUtkin OriginalUtkin self-assigned this Mar 7, 2022
version_in_master=$(eval "git show origin/master:$version_file | $command")

if (! is_output_valid $version_in_branch) || (! is_output_valid $version_in_master); then
echo "Version update is not correct"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may be beneficial to provide what is the version - in case of error it can be something else than what is in master/current branch.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, can be done by moving echo commands ("Version in branch", "Version in master") before that if

if [[ ("$2" == "poetry") || (("$2" == "") && ( -f pyproject.toml)) ]]; then
function is_output_valid() {
line_numbers=$(eval "echo $1 | wc -l")
is_version_correct=$(eval "echo $1 | grep -E '[0-9.]?'")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that 0-9.]? is enough.
As I said, if git something will fail, the version can contain some error message which is easily matched by this 0-9.]? regexp. I suggest ^([0-9]+\.)+[0-9]+$ which is strict and covers all our existing versions.
In case it will not cover some versions, we can update it later according the needs.

version_in_master=$(eval "git show origin/master:$version_file | $command")

if (! is_output_valid $version_in_branch) || (! is_output_valid $version_in_master); then
echo "Version update is not correct"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, can be done by moving echo commands ("Version in branch", "Version in master") before that if


if [[ ("$2" == "poetry") || (("$2" == "") && ( -f pyproject.toml)) ]]; then
function is_output_valid() {
line_numbers=$(eval "echo $1 | wc -l")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably no need to use eval here

version_file="pyproject.toml"
command="poetry version -s"
elif [[ ("$2" == "version_file") || (("$2" == "") && ( -f VERSION)) ]]; then
command="sed 's/[\ \"]*//g' | grep -E '(^\[tool\.poetry\])|(^version)' | sed -E 's/\[tool.poetry\]//g' | sed -E 's/version[[:blank:]]?=[[:blank:]]?//g'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consider using functions instead of string command:

function cmd1() { echo "cmd1" }
function cmd2() { echo "cmd2" }

alias chosen_command='cmd1'
chosen_command  # calls cmd1

``

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I think it is possible to pipe output of previous command as the input of the function, please check https://stackoverflow.com/a/11454477/1768976

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants