ruby - Simple Regex test in shell for commit message -
i'm new shell , need port simple commit-msg hook written in ruby, problem on regex test, can help?
this code in ruby:
#!/usr/bin/env ruby message_file = argv[0] message = file.read(message_file) $regex = /\[([a-z]+)-\d+\](.)*/ if !$regex.match(message) puts "[error] please use following pattern: '[abc-123] lorem ipsum'" exit 1 end
in sh script be
#!/bin/sh if echo $1 | egrep -qv '\[([a-z]+)-\d+\](.)*'; echo "[error] please use following pattern: '[abc-123] lorem ipsum'" exit 1; fi
Comments
Post a Comment