diff --git a/.github/workflows/commit-msg.yml b/.github/workflows/commit-msg.yml new file mode 100644 index 00000000000000..44ecba2fb14928 --- /dev/null +++ b/.github/workflows/commit-msg.yml @@ -0,0 +1,18 @@ +name: Commit Message Check + +on: [push, pull_request] + +jobs: + ubuntu64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Fetch OBS Studio master + run: | + git fetch https://github.com/obsproject/obs-studio.git + + - name: Check the log messages + run: | + git log --format=full FETCH_HEAD.. | ./CI/check-log-msg.awk diff --git a/CI/check-log-msg.awk b/CI/check-log-msg.awk new file mode 100755 index 00000000000000..972f6dc237fe63 --- /dev/null +++ b/CI/check-log-msg.awk @@ -0,0 +1,73 @@ +#! /bin/awk -f + +BEGIN { + ret = 0 +} + +{ + if (/^commit /) { + state = 1 + commit = $2 + is_merge = 0 + } + else if (state==1 && /^$/) state = 2 + else if (state==2) state = 3 + else if (state==3) state = 4 +} + +state==1 && $1=="Merge:" { + is_merge = 1 +} + +function check_module_name(mod) { + if (mod ~ /^(win-capture|rtmp-services|obs-ffmpeg|CI|pipewire):$/) + return + if (mod ~ /^(libobs|deps|docs|UI)(|\/[a-z_-]*):$/) + return + if (mod ~ /^(obs-filters|obs-outputs|win-dshow|cmake|obs-browser):$/) + return + if (mod ~ /^(libobs-opengl|linux-capture|image-source|decklink):$/) + return + if (mod ~ /^(obs-transitions|enc-amf|frontend-tools):$/) + return + print "Warning: not frequently appearing module name: "mod +} + +state==3 && !is_merge { + title = gensub(/^ */, "", 1, $0) + if (title ~ /^Revert ".*"$/) { + next + } + + if (title ~ /^[A-Za-z0-9./-]*(, ?[A-Za-z0-9/-]*)*: /) { + title1 = gensub(/^[^:]*: /, "", 1, title) + mod = $1 + check_module_name(mod) + } else { + title1 = title + mod = "" + } + + split(title1, title_a, / /) + if (title_a[1] !~ /^([A-Z][a-z]*|Don't)$/) { + print "Error: commit "commit": first word: "title_a[1] + ret = 1 + } + + if (length(title1) > 50) { + print "Error: commit "commit": too long title: "title + ret = 1 + } +} + +state==4 { + line = gensub(/^ */, "", 1, $0) + if (length(line) > 72) { + print "Error: commit "commit": too long description in a line: "line + ret = 2 + } +} + +END { + exit(ret) +}