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
packit, don't touch version, change release #748
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
import datetime | ||
import logging | ||
import os | ||
import re | ||
|
@@ -466,11 +467,49 @@ def fix_spec(self, archive: str, version: str, commit: str): | |
:param version: version to set in the spec | ||
:param commit: commit to set in the changelog | ||
""" | ||
# we only care about the first number in the release | ||
# so that we can re-run `packit srpm` | ||
original_release_number = self.specfile.get_release_number().split(".", 1)[0] | ||
|
||
current_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S%f") | ||
|
||
git_des_command = [ | ||
"git", | ||
"describe", | ||
"--tags", | ||
"--long", | ||
"--dirty", | ||
"--match", | ||
"*", | ||
] | ||
try: | ||
git_des_out = run_command(git_des_command, output=True).strip() | ||
except PackitCommandFailedError as ex: | ||
logger.info(f"Exception while describing the repository: {ex}") | ||
# probably no tags in the git repo | ||
git_desc_suffix = "" | ||
else: | ||
# git adds various info in the output separated by - | ||
# so let's just drop version and reuse everything else | ||
g_desc_raw = git_des_out.split("-", 1)[1] | ||
# release components are meanto to be separated by ".", not "-" | ||
git_desc_suffix = "." + g_desc_raw.replace("-", ".") | ||
# instead of changing version, we change Release field | ||
# upstream projects should take care of versions | ||
template = "{original_release_number}.{current_time}{git_desc_suffix}" | ||
self._fix_spec_source(archive) | ||
self._fix_spec_prep(version) | ||
|
||
msg = f"- Development snapshot ({commit})" | ||
self.specfile.set_spec_version(version=f"{version}", changelog_entry=msg) | ||
release = template.format( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would using a format-string and dropping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uuhhhhhhhhhhhhhhhh |
||
original_release_number=original_release_number, | ||
current_time=current_time, | ||
git_desc_suffix=git_desc_suffix, | ||
) | ||
logger.debug(f"Setting Release in spec to {release!r}") | ||
self.specfile.set_spec_version( | ||
version=version, release=release, changelog_entry=msg, | ||
) | ||
|
||
def _fix_spec_prep(self, version): | ||
prep = self.specfile.spec_content.section("%prep") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work for all projects? Are tags always versions only? The reason for asking is b/c in git.centos.org, I see tags like
imports/c8/rpm-4.14.2-25.el8
, which also contain a version, but they will fail to be processed this way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's git-describe specific, it uses dashes to separate different data - sadly one cannot format it
yeah, we may need to polish this for centos stream - or figure out how to operate with release and version - we will be in control of the repos, so we may use more sensible tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what I wrote is bullshit, I thought we're talking about something else - in your case, curse all the people who use dashes in tags