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

Better machine-readable log output #170

Closed
UberMouse opened this issue Jul 20, 2020 · 2 comments
Closed

Better machine-readable log output #170

UberMouse opened this issue Jul 20, 2020 · 2 comments

Comments

@UberMouse
Copy link

As is it stands currently we shell out to git-log when calling sno log. This means we are limited to the settings git-log supports for creating machine-readable log output, namely, --pretty. Current log output for machine consumption is generated with the following git-log arguments

  const prettyFormat = [
    "%H", // SHA
    "%h", // short SHA
    "%s", // summary
    "%b", // body
    // author identity string, matching format of GIT_AUTHOR_IDENT.
    //   author name <author email> <author date>
    // author date format dependent on --date arg, should be raw
    "%an <%ae> %ad",
    "%cn <%ce> %cd",
    "%P", // parent SHAs,
    "%(trailers:unfold,only)",
  ].join(`%x${delimiter}`);

--stat --date=raw -z --no-show-signature --no-color --pretty=${prettyFormat}.

Currently, everything in prettyFormat is parsed out of a commit, except for the trailers, trailers are currently ignored.

Problems with --pretty

  1. It is only aware of git concepts so we can't extract any sno specific information (ie also show me which datasets have been modified in this commit)
  2. It's a pretty esoteric format
  3. We can't extend it because it's part of git-log

I don't have any thoughts or opinions on how this should be done at this stage, or what format would be better. This is just to collect issues that need to be resolved as part of improving what machine-readable information we can pull out.

Problems found through usage

  1. We want the ability to commits differently depending on their "location", ie whether they are a new commit and have not been pushed, or a commit that has been pushed, or a commit that has been fetched and not merged. Currently, this is handled by performing 3x calls to sno log filtering the commits by that criteria and merging the results
  2. There's no way to extract this information with --pretty. Something workable is to include --stat and then parse the stat information but it' pretty awful, delimiters aren't in the right places so the stat output ends up on the wrong line and it's human-readable text
@olsen232
Copy link
Collaborator

Somewhat addressed by #177 - try sno log -o json --dataset-changes

@olsen232
Copy link
Collaborator

olsen232 commented Jul 7, 2021

I'm closing this for now -

  • machine readability is handled with -o json, and --dataset-changes
  • three simultaneous calls to log is not ideal, but not the worst either. A single call to kart log will suffice if you are willing to parse the parents to split it into three parts. It's tricky (and not git-standard) to find another way to output logs that not only makes parsing easier, but also works well for edge cases like multiple merge-parent candidates.

@olsen232 olsen232 closed this as completed Jul 7, 2021
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

No branches or pull requests

2 participants