diff --git a/files/check.sh b/files/check.sh index 7718b5d..598fee6 100644 --- a/files/check.sh +++ b/files/check.sh @@ -22,15 +22,16 @@ rm -f /tmp/comments.json touch /tmp/comments.json while read FILE; do + COMMIT=$(git log --pretty=format:"%H" -1 "$FILE"); echo -n "Проверка изменений в файле $FILE на опечатки... "; cat "$FILE" | sed 's/https\?:[^ ]*//g' | sed "s/[(][^)]*\.md[)]//g" | sed "s/[(]files[^)]*[)]//g" | hunspell -d dictionary,russian-aot-utf8,ru_RU,de_DE-utf8,en_US-utf8 > /tmp/hunspell.out cat /tmp/hunspell.out | hunspell_parser > /tmp/hunspell_parsed.json - /tmp/check_spell -file "$FILE" -pr-liner /tmp/pr_liner.json -hunspell-parsed-file /tmp/hunspell_parsed.json >> /tmp/comments.json + /tmp/check_spell -file "$FILE" -commit=$COMMIT -pr-liner /tmp/pr_liner.json -hunspell-parsed-file /tmp/hunspell_parsed.json >> /tmp/comments.json echo -n "Проверка изменений в файле $FILE на недоступные ссылки... "; - /tmp/check_links -file "$FILE" -pr-liner /tmp/pr_liner.json -expected-codes files/expected_codes.csv >> /tmp/comments.json + /tmp/check_links -file "$FILE" -commit=$COMMIT -pr-liner /tmp/pr_liner.json -expected-codes files/expected_codes.csv >> /tmp/comments.json echo done < /tmp/changed_files diff --git a/files/check_links.go b/files/check_links.go index 9824a2d..942faf9 100644 --- a/files/check_links.go +++ b/files/check_links.go @@ -16,10 +16,11 @@ import ( func main() { prLiner := flag.String("pr-liner", "", "Pull request liner") fileName := flag.String("file", "", "Hunspell parsed file name") + commit := flag.String("commit", "", "Commit") expectedCodesFile := flag.String("expected-codes", "", "Expected codes file name") flag.Parse() - if *prLiner == "" || *fileName == "" || *expectedCodesFile == "" { + if *prLiner == "" || *fileName == "" || *commit == "" || *expectedCodesFile == "" { flag.Usage() os.Exit(1) } @@ -63,11 +64,10 @@ func main() { } body := fmt.Sprintf("Ссылка %s ... недоступна с кодом %v, ожидается %v. Если это ожидаемый ответ, внесите \"%v,%s\" в files/expected_codes.csv", link, respCode, expectedCodes, respCode, link) - commitID := "FIXME XXX" comment := &github.PullRequestComment{ Body: &body, - CommitID: &commitID, + CommitID: commit, Path: fileName, Position: &prLine, } diff --git a/files/check_spell.go b/files/check_spell.go index 814e81e..7659f7e 100644 --- a/files/check_spell.go +++ b/files/check_spell.go @@ -14,9 +14,10 @@ func main() { prLiner := flag.String("pr-liner", "", "Pull request liner") hunspellParsedFile := flag.String("hunspell-parsed-file", "", "Hunspell parsed file name") file := flag.String("file", "", "Hunspell parsed file name") + commit := flag.String("commit", "", "Commit") flag.Parse() - if *prLiner == "" || *hunspellParsedFile == "" || *file == "" { + if *prLiner == "" || *hunspellParsedFile == "" || *file == "" || *commit == "" { flag.Usage() os.Exit(1) } @@ -33,11 +34,10 @@ func main() { } body := fmt.Sprintf("Возможная ошибка в слове \"%s\", варианты правильного написания \"%s\". Если слово \"%s\" является правильным, добавьте его в files/dictionary.dic", resp.Word, resp.Alternative, resp.Word) - commitID := "FIXME XXX" comment := &github.PullRequestComment{ Body: &body, - CommitID: &commitID, + CommitID: commit, Path: file, Position: &prLine, }