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

dh-make-golang make: directly use the user preferred tag specified in "-git_revision" option #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wlyu2
Copy link

@wlyu2 wlyu2 commented Nov 27, 2024

When a user specifies a valid tag when using

dh-make-golang make -git_revision {some valid tag}

if there is another tag pointing to the same commit as the specified tag, then dh-make-golang might use the other tag to determine the package version.

This patch modifies the behavior of "dh-make-golang make" such that, if the user specifies a valid tag in "-git_revision" option, "dh-make-golang make" will always use the specified tag to determine the upstream package version.

This patch also trivially changes the tests written in version_test.go so that the tests adjusts to the new function signature of version.go:pkgVersionFromGit().

… "-git_revision" option

When a user specifies a valid tag when using

    dh-make-golang make -git_revision {some valid tag}

if there is another tag pointing to the same commit as the specified
tag, then dh-make-golang might use the other tag to determine the
package version.

This patch modifies the behavior of "dh-make-golang make" such that, if
the user specifies a valid tag in "-git_revision" option,
"dh-make-golang make" will always use the specified tag to determine the
upstream package version.

This patch also trivially changes the tests written in version_test.go
so that the tests adjusts to the new function signature of
version.go:pkgVersionFromGit().

Signed-off-by: William Lyu <[email protected]>
@wlyu2
Copy link
Author

wlyu2 commented Nov 27, 2024

This patch attempts to fix #226 .

goto FoundLatestTag
}
}

Copy link
Author

Choose a reason for hiding this comment

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

These are some comments regarding why I use a goto statement. Please let me know if there are better alternatives.

I want to use the git describe heuristics as a fallback in case I cannot verify if the user specified git revision is valid or not.

The logic I want to implement is:

if (u.rr is valid (which makes u.rr.VCS.Tags meaningful) and the user specified tag exists as a valid tag) {
    set the latest tag to this user specified tag
} else {
    the fallback heuristics
}

However, to implement the "if" part of the above pseudocode, I cannot find a way to implement it as a single if clause. This will result in the "else" part being written out twice, and I want to avoid such duplication.

In other words, I am trying to deal with the problem in this post: https://stackoverflow.com/questions/13197425/multiple-if-with-one-else

William

@ottok
Copy link
Contributor

ottok commented Jan 14, 2025

Does @n-peugnet or @Maytha8 want to review/approve this?

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