-
Notifications
You must be signed in to change notification settings - Fork 20
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
describe-commit: New script to describe commits in terms of refs #12
base: master
Are you sure you want to change the base?
Conversation
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.
Two minor comments, otherwise looks good.
describe-commit
Outdated
rev) | ||
if commit is None: | ||
break | ||
refmap[rev].append((depth, ref + depth * '^')) |
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.
At some point we should add '~42` syntax like to ostree if we do more stuff like this.
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.
Yeah, I've thought about it many times but never spent the time to try to code it.
while True: | ||
_, commit = repo.load_variant_if_exists(OSTree.ObjectType.COMMIT, | ||
rev) | ||
if commit is None: |
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.
This also silently exits if the user typo'd a checksum. Is that intentional? We already break out below if there's no parent.
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.
Oh, I hadn't thought about that case. The reason this silently breaks is to catch the case that the parent commit is missing. The case below is when the commit doesn't actually have a parent. Perhaps this just needs to check if depth is 0 and raise an exception since that would represent the checksum that the user passed in.
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.
Actually this part is not coupled to the checksum that was passed in by the user. This loop is entirely about building up names for referenced commits and their parents. I can add a warning or error if the commit pointed to by the ref itself (depth == 0
) does not exist. What do you think?
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 turned this into an error if the ref is pointing to a non-existent commit. See below.
describe-commit
Outdated
from gi.repository import GLib, Gio, OSTree | ||
import sys | ||
|
||
def commit_describe(repo, checksum, all_refs=True): |
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.
all_refs=True
This should be False
by default, right?
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.
Yeah, I think so since that matches the CLI default. I almost always run it with --all
since I'm usually trying to figure out if a commit can be pruned or not, but I think for consistency you're right.
This is similar to git-describe(1) in that it takes a commit checksum and describes the commit in terms of refs. This is useful if you have a repository with a lot of commits and need to do some non-standard pruning.
1cb66f1
to
6c59562
Compare
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 I addressed the comments now.
while True: | ||
_, commit = repo.load_variant_if_exists(OSTree.ObjectType.COMMIT, | ||
rev) | ||
if commit is None: |
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.
Oh, I hadn't thought about that case. The reason this silently breaks is to catch the case that the parent commit is missing. The case below is when the commit doesn't actually have a parent. Perhaps this just needs to check if depth is 0 and raise an exception since that would represent the checksum that the user passed in.
describe-commit
Outdated
rev) | ||
if commit is None: | ||
break | ||
refmap[rev].append((depth, ref + depth * '^')) |
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.
Yeah, I've thought about it many times but never spent the time to try to code it.
describe-commit
Outdated
from gi.repository import GLib, Gio, OSTree | ||
import sys | ||
|
||
def commit_describe(repo, checksum, all_refs=True): |
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.
Yeah, I think so since that matches the CLI default. I almost always run it with --all
since I'm usually trying to figure out if a commit can be pruned or not, but I think for consistency you're right.
while True: | ||
_, commit = repo.load_variant_if_exists(OSTree.ObjectType.COMMIT, | ||
rev) | ||
if commit is None: |
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.
Actually this part is not coupled to the checksum that was passed in by the user. This loop is entirely about building up names for referenced commits and their parents. I can add a warning or error if the commit pointed to by the ref itself (depth == 0
) does not exist. What do you think?
while True: | ||
_, commit = repo.load_variant_if_exists(OSTree.ObjectType.COMMIT, | ||
rev) | ||
if commit is None: |
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 turned this into an error if the ref is pointing to a non-existent commit. See below.
This is similar to git-describe(1) in that it takes a commit checksum
and describes the commit in terms of refs. This is useful if you have a
repository with a lot of commits and need to do some non-standard
pruning.