Now I have to check for the presence of any of the strings "Added, Changed, Fixed, Deleted" in the message. Will give me the commit message that the user has entered. r recursively searches the directory, -o will 'show only the part of a line matching PATTERN' - this is what splits up multiple occurences on a single line and makes grep print each match on a new line then pipe those newline-separated-results back into grep with -c to count the number of occurrences using the same pattern. In the above code, $SVNLOOK log "$REPOS" -t "$TXN" Assuming all your strings to check are in a file strings.txt, and the file you want to check in is input.txt, the following one liner will do : Updated the answer based on comments : diff <( sort -u strings.txt ) <( grep -o -f strings.txt input.txt sort -u ) Explanation : Use greps -o option to match only the strings you are interested in. ![]() A simple pattern example would be: w foo bar baz.grep (/foobar/) > 'foo', 'bar' means 'or', so the pattern. I am writing an svn precommit hook, and the expected commit comment should have one of these 4 strings in the message. It isn't entirely clear what you're asking, but from the context it looks like you want a pattern that can be used to search for multiple entries in an array, since readlines returns an array containing the lines of the file. I need to check if any of the strings 'Added/Changed/Fixed/Deleted' are in a commit log message. "$"Įcho "Your commit has been blocked because you didn't give any log message" 1>&2Įcho "Please write a log message describing the purpose of your changes and" 1>&2Įcho "then try committing again. grep for multiple strings in a single line. I am writing an svn precommit hook, and the expected commit comment should have one of these 4 strings in the message. I need to check if any of the strings "Added/Changed/Fixed/Deleted" are in a commit log message.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |