Last active
December 22, 2015 13:58
-
-
Save drinkcat/6482317 to your computer and use it in GitHub Desktop.
awk version of branch matching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ADHD_HEAD="`awk ' | |
| BEGIN { | |
| crosver = "'"$CROS_VER"'" | |
| crosvers[0] = crosver | |
| while (sub(/\.[^.]*$/, "", crosver)) | |
| crosvers[length(crosvers)] = crosver | |
| bestmatch = length(crosvers)-1 | |
| } | |
| sub(/refs\/heads\//, "", $2) { | |
| if ($2 ~ "^release-R[0-9]*-" crosvers[length(crosvers)-1] "([^0-9].*)*$") { | |
| print $2 | |
| exit | |
| } | |
| for (i = 0; i <= bestmatch; i++) { | |
| if ($2 ~ "^stabilize-" crosvers[i] "([^0-9].*)*$") { | |
| out = ((i < bestmatch) ? "" : out) $2 "\n" | |
| bestmatch = i | |
| } | |
| } | |
| } | |
| END { printf "%s", out; } | |
| ' adhd.refs | sort -V | tail -n 1`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment