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

Add support for %ci, %h and @TAG_OFFSET@ to obsinfo files #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions TarSCM/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ def create_archive(self, scm_object, **kwargs):

if commit:
metafile.write("commit: " + commit + "\n")
names = {"%ci": "commit_date: ",
"%h": "short_commit_hash: ",
"@TAG_OFFSET@": "commits_since_last_tag: "}

for field in ("%h", "%ci", "@TAG_OFFSET@"):
fake_args = args.copy()
fake_args["versionformat"] = field
value = str(scm_object.detect_version(fake_args))
metafile.write(names[field] + value + "\n")

Copy link
Collaborator

Choose a reason for hiding this comment

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

looks very specific to git to me. Maybe this should be handled in a SCM specific method and TarSCM.scm.base should have a generic method which simply 'pass'. Otherwise I guess it could break e.g. svn/bzr/...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I agree, git-specific stuff should remain in the Git class.

metafile.close()

Expand Down