Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use upstream_tag_template to get version from tag #959

Merged
merged 3 commits into from Sep 22, 2020
Merged

Use upstream_tag_template to get version from tag #959

merged 3 commits into from Sep 22, 2020

Conversation

sakalosj
Copy link
Contributor

@sakalosj sakalosj commented Sep 9, 2020

Use package config variable upstream_tag_template to extract version
from git tag.

TODO:

@packit-as-a-service-stg
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/packit-packit-959-stg
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@softwarefactory-project-zuul

This comment has been minimized.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@sakalosj
Copy link
Contributor Author

@jkonecny12

As discussed on IRC this PR fixed your issue

@jkonecny12
Copy link
Contributor

jkonecny12 commented Sep 10, 2020

Thank you a lot. I will finally be able to remove the workarounds we have ;)

Copy link
Member

@jpopelka jpopelka left a comment

Choose a reason for hiding this comment

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

Is this still WIP?

@sakalosj
Copy link
Contributor Author

Is this still WIP?

the code part is finished, only integration tests and documentation is missing
I have updated the description with this info

# raw_version - version before processing by Upstream.get_version_from_tag()
raw_ver = self.command_handler.run_command(
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if the comment gives us any new value.

Suggested change
# raw_version - version before processing by Upstream.get_version_from_tag()
raw_ver = self.command_handler.run_command(
raw_ver = self.command_handler.run_command(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

self.package_config.current_version_command,
return_output=True,
cwd=self.local_project.working_dir,
).strip()
logger.debug(f"Version: {ver}")
Copy link
Member

Choose a reason for hiding this comment

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

Don't we want to log it? Or both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 885 to 892
try:
return p.match(tag).group(field)
except (IndexError, AttributeError):
logger.error(
f'Unable to extract "{field}" from {tag} using '
f"{self.package_config.upstream_tag_template}"
)
raise
Copy link
Member

Choose a reason for hiding this comment

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

I am looking for the time we can be python>=3.8 only and use Assignment Expressions.

But I would still try to avoid unnecessary try-except when not needed...

Suggested change
try:
return p.match(tag).group(field)
except (IndexError, AttributeError):
logger.error(
f'Unable to extract "{field}" from {tag} using '
f"{self.package_config.upstream_tag_template}"
)
raise
match = p.match(tag)
if match and field in match.groups():
return match.group(field)
else:
msg = (
f'Unable to extract "{field}" from {tag} using '
f"{self.package_config.upstream_tag_template}"
)
logger.error(msg)
raise PackitException(msg)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

why you prefer if...else over try...except when dealing with unwanted errors?

Comment on lines 38 to 40
mock = flexmock(synced_files=None, upstream_package_name=upstream_package_name)
mock.should_receive("current_version_command")
return mock
Copy link
Member

Choose a reason for hiding this comment

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

You can use mock method to get the original flexmock instance:

Suggested change
mock = flexmock(synced_files=None, upstream_package_name=upstream_package_name)
mock.should_receive("current_version_command")
return mock
return flexmock(
synced_files=None,
upstream_package_name=upstream_package_name
).should_receive("current_version_command").mock()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@lachmanfrantisek lachmanfrantisek linked an issue Sep 15, 2020 that may be closed by this pull request
3 tasks
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj sakalosj changed the title WIP: Use upstream_tag_template to get version from tag Use upstream_tag_template to get version from tag Sep 21, 2020
@sakalosj sakalosj added the ready-for-review Pull request is ready for review. label Sep 21, 2020
Use package config variable upstream_tag_template to extract version
from git tag.
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj
Copy link
Contributor Author

recheck

1 similar comment
@sakalosj
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj
Copy link
Contributor Author

recheck

1 similar comment
@sakalosj
Copy link
Contributor Author

sakalosj commented Sep 21, 2020

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@sakalosj sakalosj added the mergeit When set, zuul wil gate and merge the PR. label Sep 21, 2020
@sakalosj sakalosj merged commit 2618f9f into packit:master Sep 22, 2020
@sakalosj
Copy link
Contributor Author

@jkonecny12
finally fix is merged, and it will be available in the next release, which should be available by the end of this week.
the current release is 0.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mergeit When set, zuul wil gate and merge the PR. ready-for-review Pull request is ready for review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Archive name instead of package name in %prep section upstream_tag_template not used during srpm build
5 participants