-
Notifications
You must be signed in to change notification settings - Fork 146
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 commit hash/version in footer #323
base: master
Are you sure you want to change the base?
Conversation
elixir/web_utils.py
Outdated
if re.match('^[0-9a-f]{5,12}$', version) or version.startswith('v'): | ||
return f'https://github.com/bootlin/elixir/tree/{ version }' | ||
else: | ||
return f'https://github.com/bootlin/elixir/' |
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 am not convinced this is useful. I'd vote for always returning the standard repo link and trust people can navigate to find the repo version / hash being displayed on the page.
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 think this is useful, and when I see a commit hash, I would expect to be redirected to a particular commit. The link to a particular version can be separate if you think this helps.
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.
The only problem is that the linked version may not exist in the upstream repo if someone hosts their own. But maybe this is actually good, it signifies that it's a custom instance
) | ||
|
||
if return_code == 0: | ||
return result.decode('utf-8') |
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.
If return code is non-zero but nothing is emitted to stderr, we get no error log and return the default "v2.2" silently.
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.
run_cmd logs errors
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.
No: run_cmd()
logs only when something is emitted to stderr. Something can fail (return_code != 0
) but not emit anything on stderr.
I think get_elixir_version_string()
should be more like (this is a proof-of-concept, not tested):
def get_elixir_version_string():
version = os.environ.get('ELIXIR_VERSION')
if version is not None and len(version) != 0:
return version
try:
# try to get Elixir version from git
result, return_code = run_cmd('git',
'-C', ELIXIR_DIR,
'-c', f'safe.directory={ os.path.normpath(ELIXIR_DIR) }',
'rev-parse', '--short', 'HEAD'
)
if return_code != 0:
raise ValueError(f"git rev-parse returned {return_code}")
return result.decode('utf-8')
except Exception as e:
logging.exception(f"failed to get elixir commit hash: {e}")
return ''
Edit: or it could be run_cmd()
that is modified to log whenever p.returncode
is non-zero.
1323f65
to
3923b4c
Compare
No description provided.