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

tools/shellcheck: git log ${TRAVIS_COMMIT_RANGE/.../..} #192

Merged
merged 1 commit into from Apr 28, 2020

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Apr 16, 2020

$TRAVIS_COMMIT_RANGE contains triple dots,
e.g. "origin/master...HEAD". This is great for git diff but unsuitable
for git log. Convert any triple dots to double dots before passing to
git log (don't change the argument for git diff --name-only).

Also use a more verbose git log command and --no-pager instead of the
gross '|cat ': the sanity check was reporting issues but always
reporting success.

Fixes: faadb20 ("CI: travis: new shellcheck-gitrange.bash")

Signed-off-by: Marc Herbert marc.herbert@intel.com

@marc-hb marc-hb force-pushed the fix-travis-range branch 3 times, most recently from a3ae054 to 87211b8 Compare April 16, 2020 01:37
@marc-hb marc-hb marked this pull request as ready for review April 16, 2020 01:37
@marc-hb marc-hb closed this Apr 16, 2020
@marc-hb
Copy link
Collaborator Author

marc-hb commented Apr 16, 2020

it's not that simple, need more time.

$TRAVIS_COMMIT_RANGE contains triple dots,
e.g. "origin/master...HEAD". This is great for git diff but unsuitable
for git log. Convert any triple dots to double dots before passing to
git log (don't change the argument for git diff --name-only).

Also use a more verbose git log command and --no-pager instead of the
gross '|cat ': the sanity check was reporting issues but always
reporting success.

Fixes: faadb20 ("CI: travis: new shellcheck-gitrange.bash")

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb marc-hb reopened this Apr 16, 2020
@marc-hb marc-hb changed the title CI: travis: fix ${TRAVIS_COMMIT_RANGE/.../..} tools/shellcheck: git log ${TRAVIS_COMMIT_RANGE/.../..} Apr 16, 2020
@ranj063
Copy link
Contributor

ranj063 commented Apr 22, 2020

@marc-hb I dont understand why you need ... for git diff and .. for git log. I'd think that in both cases .. should suffice. The difference between the 2 as I understand is whether the starting commit SHA1 is included or not.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Apr 22, 2020

The difference between the 2 as I understand is whether the starting commit SHA1 is included or not.

Nope.

https://matthew-brett.github.io/pydagogue/pain_in_dots.html#pain-in-dots

The triple dots is needed for git diff because it makes G...C below start from E, which is great. We want F and G to be excluded and not pollute the output of git diff --name-only

        A---B---C pull request
       /
--D---E---F---G master

That's why $TRAVIS_COMMIT_RANGE contains a triple dot and why this PR doesn't change anything to the git diff --name-only command.

Could/should $TRAVIS_COMMIT_RANGE provide a more direct double-dot E..C instead? Maybe but more work for Travis when git's triple dot provides this "for free".

This PR removes the triple dot for git log because the triple dot has a totally different (and almost "opposite"?!) meaning for git log! Thank you git...

@ranj063
Copy link
Contributor

ranj063 commented Apr 22, 2020

The difference between the 2 as I understand is whether the starting commit SHA1 is included or not.

Nope.

https://matthew-brett.github.io/pydagogue/pain_in_dots.html#pain-in-dots

The triple dots is needed for git diff because it makes G...C below start from E, which is great. We want F and G to be excluded and not pollute the output of git diff --name-only

        A---B---C pull request
       /
--D---E---F---G master

That's why $TRAVIS_COMMIT_RANGE contains a triple dot and why this PR doesn't change anything to the git diff --name-only command.

Could/should $TRAVIS_COMMIT_RANGE provide a more direct double-dot E..C instead? Maybe but more work for Travis when git's triple dot provides this "for free".

This PR removes the triple dot for git log because the triple dot has a totally different (and almost "opposite"?!) meaning for git log! Thank you git...

@marc-hb I am probably missing the bigger picture of how this range gets used. What are we doing with the diff and log?

@marc-hb
Copy link
Collaborator Author

marc-hb commented Apr 22, 2020

@marc-hb I am probably missing the bigger picture of how this range gets used. What are we doing with the diff and log?

Extracting and showing filenames and commits of the PR and only of the PR.

This PR removes the triple dot for git log because the triple dot has a totally different (and almost "opposite"?!) meaning for git log!

Opposite indeed. This is not just for TRAVIS_COMMIT_RANGE; a diff with double dots matches a log with triple dots and vice versa in pretty much every context:

          *---*---PR   (Pull Request)
         /
--*---base---*----upstream

     Double dots        |  Triple dots
       upstream..PR     |        upstream...PR
------------------------+--------------------------
diff   upstream  PR "V" |  base             PR "/" 
log    ^base     PR "/" | ^base  upstream   PR "V"

@ranj063
Copy link
Contributor

ranj063 commented Apr 22, 2020

Extracting and showing filenames and commits of the PR and only of the PR.

@marc-hb typically we do a rebase and merge for PR's isnt it? So, why not checkout the PR locally and rebase on top of master. Then a .. would suffice for both cases? Maybe Im oversimplifying

@marc-hb
Copy link
Collaborator Author

marc-hb commented Apr 22, 2020

So, why not checkout the PR locally and rebase on top of master.

Ideally, CI would test every PR BOTH before and after rebase.

In practice testing only before rebase is much simpler and is what the SOF project does right now. This small logging change merely adjusts to this reality and to git's broken user interface.

[off topic]
upstream is a moving target so testing after rebase is more complex and can create confusion, especially when not "done right". For instance in a previous project I saw failures happening only on some specific hardware even though my PR was not hardware specific at all. It just happened that some other, totally unrelated and hardware specific change got merged right in the middle of my PR!

@ranj063
Copy link
Contributor

ranj063 commented Apr 22, 2020

Ideally, CI would test every PR BOTH before and after rebase.

In practice testing only before rebase is much simpler and is what the SOF project does right now. This small logging change merely adjusts to this reality and to git's broken user interface.

@marc-hb fair enough. Lets go ahead with the change.

local logrange=${diffrange/.../..}
( set -x
# also a sanity check of the argument
git --no-pager log --oneline --graph --stat --max-count=40 "$logrange" --
Copy link
Contributor

Choose a reason for hiding this comment

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

@marc-hb I'm not very clear on this part. We are using git log to check whether the argument $1 is set right or not? If so, why don't we use git diff directly here? This may be a little same with @ranj063's question.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This git log command shows which commits are being checked for logging purposes. It also aborts the script early if "$1" is not valid.

The git diff command below extracts all the names of the files (fname) modified by the PR

Those are two different operations that need different commands with a slightly different argument. I'm not sure I understand the question.

Copy link
Contributor

Choose a reason for hiding this comment

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

@libinyang I believe git log is still the correct command for doing the sanity check, so this seems correct.

Copy link
Contributor

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Looks good to me!

local logrange=${diffrange/.../..}
( set -x
# also a sanity check of the argument
git --no-pager log --oneline --graph --stat --max-count=40 "$logrange" --
Copy link
Contributor

Choose a reason for hiding this comment

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

@libinyang I believe git log is still the correct command for doing the sanity check, so this seems correct.

@marc-hb marc-hb merged commit 8a4b991 into thesofproject:master Apr 28, 2020
@marc-hb
Copy link
Collaborator Author

marc-hb commented Apr 28, 2020

Thanks @kv2019i and @ranj063

This is merely tweaking the argument of a log command and I submitted this 2 weeks ago so I've taken the "risk" to merge this with only 1.5 approvals.

@marc-hb marc-hb deleted the fix-travis-range branch April 28, 2020 23:15
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.

None yet

4 participants