-
Notifications
You must be signed in to change notification settings - Fork 55
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
Implement getter of SHA for branches #668
Implement getter of SHA for branches #668
Conversation
Build succeeded.
|
@csomh @TomasTomecek @lachmanfrantisek I would also like some opinion on the # BaseProject
def get_sha_from(branch: str = None, tag: str = None) -> Optional[str]:
# check if provided «exactly» one of ‹branch› or ‹tag›
# throw exception if not
return None
# projects
def get_sha_from(branch: str = None, tag: str = None) -> Optional[str]:
super().get_sha_from(branch=branch, tag=tag)
if branch:
# code for SHA of branch
pass
# code for SHA of tag
return None On the bright side, I like the idea of only one function, doing only one thing (that is getting the SHA, regardless whether of tag or branch). On the other side, I don't like the way it has to be implemented, SRP of it and I also feel like factoring out getting SHA of branch and tag, which basically means we could end up with 3 functions:
↑ this also changes the TODO from «changing» to «extending» interface And my judgement might be also affected by „indentation hell“, because both Git(Hub|Lab) throw an exception if the branch doesn't exist, so it looks meh even without being nested in another block… |
Build succeeded.
|
To me this seems like a syntactic nuance from a user point of view: get_sha_from(branch="branch")
get_sha_from_branch("branch")
get_sha_from(tag="tag")
get_sha_from_tag("tag") And I don't have the "more Pythonic"-feeling towards any of the above :-) As you said |
ogr/abstract.py
Outdated
# TODO: Consider ‹get_sha_from(branch=None, tag=None)› | ||
def get_sha_from_branch(self, branch: str) -> Optional[str]: |
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.
I'd say having two separate methods for each is a better design :) get_sha_from
sounds like it would be too complicated and prone to errors - also with modern editors you are immediately being offered a list methods so it's easier to pick one which has narrow scope
Required for passing commit hashes from service to testing farm for merging of tests that are run on their side or usage in tmt preparation. Signed-off-by: Matej Focko <[email protected]>
Signed-off-by: Matej Focko <[email protected]>
4633bb5
to
685904e
Compare
removed |
Build succeeded.
|
Build succeeded (gate pipeline).
|
Required for passing commit hashes from service to testing farm for
merging of tests that are run on their side or usage in tmt preparation.
Signed-off-by: Matej Focko [email protected]
TODO:
get_sha_from(branch=None, tag=None) -> Optional[str]
We have introduced a new function into
ogr
that allows you to get commit SHA of the HEAD of the branch.