-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix check-line-width CI script #6326
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,19 +5,20 @@ | |
| set -e | ||
| set -o pipefail | ||
|
|
||
| BASE_ORIGIN="origin" | ||
| BASE_BRANCH_NAME="master" | ||
| LINE_WIDTH="120" | ||
| GOOD_LINE_WIDTH="100" | ||
| BASE_BRANCH="${BASE_ORIGIN}/${BASE_BRANCH_NAME}" | ||
|
|
||
| git fetch ${BASE_ORIGIN} ${BASE_BRANCH_NAME} --depth 1 | ||
| git diff --name-only ${BASE_BRANCH} -- \*.rs | ( while read file | ||
| if [ -z $CI_COMMIT_BEFORE_SHA ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is not a merge request on gitlab it won't be set.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought a merge request on github counts as that because it is all mirrored. So you say this is expected? If you say so we can work with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is expected, yes. pull requests are only branches on gitlab (not merge requests due to the nature of the mirroring). i'm also not finding it easy to understand the meaning of:
which would be the "a branch"?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A PR branched off a branch at some point of time (lets call this branch
|
||
| echo "No ancestor commit set in \$CI_COMMIT_BEFORE_SHA" | ||
| exit -1; | ||
| fi | ||
|
|
||
| git diff --name-only ${CI_COMMIT_BEFORE_SHA} -- \*.rs | ( while read file | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i assume it shouldn't be compared with the current master (three dots)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. And I expect |
||
| do | ||
| if [ ! -f ${file} ]; | ||
| then | ||
| echo "Skipping removed file." | ||
| elif git diff ${BASE_BRANCH} -- ${file} | grep -q "^+.\{$(( $LINE_WIDTH + 1 ))\}" | ||
| elif git diff ${CI_COMMIT_BEFORE_SHA} -- ${file} | grep -q "^+.\{$(( $LINE_WIDTH + 1 ))\}" | ||
| then | ||
| if [ -z "${FAIL}" ] | ||
| then | ||
|
|
@@ -29,11 +30,11 @@ do | |
| FAIL="true" | ||
| fi | ||
| echo "| file: ${file}" | ||
| git diff ${BASE_BRANCH} -- ${file} \ | ||
| git diff ${CI_COMMIT_BEFORE_SHA} -- ${file} \ | ||
| | grep -n "^+.\{$(( $LINE_WIDTH + 1))\}" | ||
| echo "|" | ||
| else | ||
| if git diff ${BASE_BRANCH} -- ${file} | grep -q "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}" | ||
| if git diff ${CI_COMMIT_BEFORE_SHA} -- ${file} | grep -q "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}" | ||
| then | ||
| if [ -z "${FAIL}" ] | ||
| then | ||
|
|
@@ -44,7 +45,7 @@ do | |
| echo "|" | ||
| fi | ||
| echo "| file: ${file}" | ||
| git diff ${BASE_BRANCH} -- ${file} | grep -n "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}" | ||
| git diff ${CI_COMMIT_BEFORE_SHA} -- ${file} | grep -n "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}" | ||
| echo "|" | ||
| fi | ||
| fi | ||
|
|
||
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 is definitely required as the master branch to compare with is not always available.
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.
Not if
$CI_COMMIT_BEFORE_SHAwould be working as that commit would be part of the history of the current branch, too.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.
not if the pull request contains more than 100 commits:
https://github.com/paritytech/substrate/blob/master/.gitlab-ci.yml#L35
(that limit had been raised because of such scenarios, but it's safer to just make sure what is compared with is present)