mihaigalos / miniboot

🏗️ An I2C bootloader for Arduino.
GNU General Public License v3.0
65 stars 18 forks source link

TRAVIS_PULL_REQUEST #16

Closed chaifeng closed 4 years ago

chaifeng commented 4 years ago

https://github.com/mihaigalos/miniboot/blob/995c22f4e18acbf5417e3205a0f455f0134b3107/scripts/post_summary.sh#L14

Should check the value of TRAVIS_PULL_REQUEST, it may be false.

Environment Variables - Travis CI

TRAVIS_PULL_REQUEST is set to the pull request number if the current job is a pull request build, or false if it’s not.

chaifeng commented 4 years ago

And also, we can put CR in a string directly

for example, change the following code

header="\`CI Auto Message\`\n---\n"

to

header="CI Auto Message

"

We cannot use \n everywhere, it depends on who uses it.

mihaigalos commented 4 years ago

Should check the value of TRAVIS_PULL_REQUEST, it may be false.

Good catch @chaifeng ! I'll create a fix for this.

And also, we can put CR in a string directly

This contains the " ` " character which is used by markdown. I like the one-line solution better! :blush:

chaifeng commented 4 years ago

One-line solution:

header='`CI Auto Message`'$'\n'$'\n'"---"$'\n'

Use $'\n' to replace c-style CR '\n', don't put $'\n' in quotes.

mihaigalos commented 4 years ago

Looks nice, I find the initial syntax more intuitive, even with escaped back-quotes. :laughing:

chaifeng commented 4 years ago

If you like the C-style syntax

printf -v header "\`CI Auto Message\`\n---\n"

Using printf to save a C-style string to the variable header, equals to:

header="\`CI Auto Message\`
---
"
mihaigalos commented 4 years ago

But what's the difference between these two following? I mean they're the same, the first is just extra calling print -v ?

printf -v header "\`CI Auto Message\`\n---\n"`

to the initial:

header="\`CI Auto Message\`\n---\n"`
chaifeng commented 4 years ago

Yes, they are similar, what about this?

printf -v push_message '`%s`\n---\n%s\n%s' "$header" "$body" "$footer"
mihaigalos commented 4 years ago

Pure. Implemented in #19.