1
0
mirror of https://github.com/ru-de/faq.git synced 2024-11-23 19:02:19 +00:00

diff and send

This commit is contained in:
Evgeniy Sokolov 2018-05-05 16:01:50 +02:00
parent 9a9cbb573f
commit b3918b9663
4 changed files with 38 additions and 35 deletions

View File

@ -27,7 +27,8 @@ for dic in $dicList
cat /usr/share/hunspell/$dic.aff | iconv --from ISO8859-1 --to UTF-8 | sed 's/SET ISO8859-1/SET UTF-8/' > /usr/share/hunspell/$dic-utf8.aff cat /usr/share/hunspell/$dic.aff | iconv --from ISO8859-1 --to UTF-8 | sed 's/SET ISO8859-1/SET UTF-8/' > /usr/share/hunspell/$dic-utf8.aff
done done
go get -u github.com/ewgRa/ci-utils/diff_liner/diff_liner go get -u github.com/ewgRa/ci-utils/utils/diff_liner
go get -u github.com/ewgRa/ci-utils/hunspell_parser/hunspell_parser go get -u github.com/ewgRa/ci-utils/utils/hunspell_parser
go get -u github.com/ewgRa/ci-utils/diff_liner/links_checker go get -u github.com/ewgRa/ci-utils/utils/github_comments_diff
go get -u github.com/ewgRa/ci-utils/utils/github_comments_send

View File

@ -36,17 +36,15 @@ while read FILE; do
echo echo
done < /tmp/changed_files done < /tmp/changed_files
# FIXME XXX: remove duplicated curl -s https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/comments > /tmp/pr_comments.json
github_comments_diff -comments /tmp/comments.json -exists-comments /tmp/pr_comments.json > /tmp/send_comments.json
OUTPUT=$(cat /tmp/comments.json | (! grep .)); OUTPUT=$(cat /tmp/comments.json | (! grep .));
OUTPUT_EXIT_CODE=$? OUTPUT_EXIT_CODE=$?
if [ $OUTPUT_EXIT_CODE -ne 0 ]; then if [ $OUTPUT_EXIT_CODE -ne 0 ]; then
while read -r COMMENT; do github_comments_send -file /tmp/send_comments.json -repo $TRAVIS_REPO_SLUG -pr $TRAVIS_PULL_REQUEST
cat $COMMENT > /tmp/comment.json
curl -s -XPOST https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST/comments?access_token=$GH_TOKEN -d @/tmp/comment.json > /tmp/git_answer.json
done < /tmp/comments.json
EXIT_CODE=1 EXIT_CODE=1
fi fi

View File

@ -6,8 +6,8 @@ import (
"flag" "flag"
"bufio" "bufio"
"regexp" "regexp"
"github.com/ewgRa/ci-utils/diff_liner" "github.com/ewgRa/ci-utils/src/diff_liner"
"github.com/ewgRa/ci-utils/links_checker" "github.com/ewgRa/ci-utils/src/links_checker"
"gopkg.in/russross/blackfriday.v2" "gopkg.in/russross/blackfriday.v2"
"encoding/json" "encoding/json"
"github.com/google/go-github/github" "github.com/google/go-github/github"
@ -42,6 +42,8 @@ func main() {
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
var comments []*github.PullRequestComment
for scanner.Scan() { for scanner.Scan() {
line++ line++
@ -63,22 +65,14 @@ func main() {
continue continue
} }
body := fmt.Sprintf("Ссылка **%s** ... недоступна с кодом **%v**, ожидается **%v**.\\nЕсли это ожидаемый ответ, внесите \"%v,%s\" в files/expected_codes.csv", link, respCode, expectedCodes, respCode, link) body := fmt.Sprintf("Ссылка **%s** ... недоступна с кодом **%v**, ожидается **%v**.\nЕсли это ожидаемый ответ, внесите \"%v,%s\" в files/expected_codes.csv", link, respCode, expectedCodes, respCode, link)
comment := &github.PullRequestComment{ comments = append(comments, &github.PullRequestComment{
Body: &body, Body: &body,
CommitID: commit, CommitID: commit,
Path: fileName, Path: fileName,
Position: &prLine, Position: &prLine,
} })
jsonData, err := json.Marshal(comment)
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
} }
} }
@ -86,4 +80,12 @@ func main() {
panic(err) panic(err)
} }
jsonData, err := json.Marshal(comments)
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
} }

View File

@ -3,8 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"github.com/ewgRa/ci-utils/diff_liner" "github.com/ewgRa/ci-utils/src/diff_liner"
"github.com/ewgRa/ci-utils/hunspell_parser" "github.com/ewgRa/ci-utils/src/hunspell_parser"
"github.com/google/go-github/github" "github.com/google/go-github/github"
"flag" "flag"
"encoding/json" "encoding/json"
@ -26,6 +26,8 @@ func main() {
hunspellParsedResp := hunspell_parser.ReadHunspellParserResponse(*hunspellParsedFile) hunspellParsedResp := hunspell_parser.ReadHunspellParserResponse(*hunspellParsedFile)
var comments []*github.PullRequestComment
for _, resp := range hunspellParsedResp { for _, resp := range hunspellParsedResp {
prLine := linerResp.GetDiffLine(*file, resp.Line) prLine := linerResp.GetDiffLine(*file, resp.Line)
@ -33,21 +35,21 @@ func main() {
continue continue
} }
body := fmt.Sprintf("Возможная ошибка в слове \"**%s**\".\\n Варианты правильного написания \"**%s**\".\\nЕсли слово \"%s\" является правильным, добавьте его в files/dictionary.dic", resp.Word, resp.Alternative, resp.Word) body := fmt.Sprintf("Возможная ошибка в слове \"**%s**\".\n Варианты правильного написания \"**%s**\".\nЕсли слово \"%s\" является правильным, добавьте его в files/dictionary.dic", resp.Word, resp.Alternative, resp.Word)
comment := &github.PullRequestComment{ comments = append(comments, &github.PullRequestComment{
Body: &body, Body: &body,
CommitID: commit, CommitID: commit,
Path: file, Path: file,
Position: &prLine, Position: &prLine,
} })
jsonData, err := json.Marshal(comment)
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
} }
jsonData, err := json.Marshal(comments)
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
} }