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:
parent
9a9cbb573f
commit
b3918b9663
@ -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
|
||||
done
|
||||
|
||||
go get -u github.com/ewgRa/ci-utils/diff_liner/diff_liner
|
||||
go get -u github.com/ewgRa/ci-utils/hunspell_parser/hunspell_parser
|
||||
go get -u github.com/ewgRa/ci-utils/diff_liner/links_checker
|
||||
go get -u github.com/ewgRa/ci-utils/utils/diff_liner
|
||||
go get -u github.com/ewgRa/ci-utils/utils/hunspell_parser
|
||||
go get -u github.com/ewgRa/ci-utils/utils/github_comments_diff
|
||||
go get -u github.com/ewgRa/ci-utils/utils/github_comments_send
|
||||
|
||||
|
@ -36,17 +36,15 @@ while read FILE; do
|
||||
echo
|
||||
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_EXIT_CODE=$?
|
||||
|
||||
if [ $OUTPUT_EXIT_CODE -ne 0 ]; then
|
||||
while read -r COMMENT; do
|
||||
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
|
||||
|
||||
github_comments_send -file /tmp/send_comments.json -repo $TRAVIS_REPO_SLUG -pr $TRAVIS_PULL_REQUEST
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"flag"
|
||||
"bufio"
|
||||
"regexp"
|
||||
"github.com/ewgRa/ci-utils/diff_liner"
|
||||
"github.com/ewgRa/ci-utils/links_checker"
|
||||
"github.com/ewgRa/ci-utils/src/diff_liner"
|
||||
"github.com/ewgRa/ci-utils/src/links_checker"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
"encoding/json"
|
||||
"github.com/google/go-github/github"
|
||||
@ -42,6 +42,8 @@ func main() {
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
|
||||
var comments []*github.PullRequestComment
|
||||
|
||||
for scanner.Scan() {
|
||||
line++
|
||||
|
||||
@ -63,22 +65,14 @@ func main() {
|
||||
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,
|
||||
CommitID: commit,
|
||||
Path: fileName,
|
||||
Position: &prLine,
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(comment)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(jsonData))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,4 +80,12 @@ func main() {
|
||||
panic(err)
|
||||
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(comments)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(jsonData))
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"github.com/ewgRa/ci-utils/diff_liner"
|
||||
"github.com/ewgRa/ci-utils/hunspell_parser"
|
||||
"github.com/ewgRa/ci-utils/src/diff_liner"
|
||||
"github.com/ewgRa/ci-utils/src/hunspell_parser"
|
||||
"github.com/google/go-github/github"
|
||||
"flag"
|
||||
"encoding/json"
|
||||
@ -26,6 +26,8 @@ func main() {
|
||||
|
||||
hunspellParsedResp := hunspell_parser.ReadHunspellParserResponse(*hunspellParsedFile)
|
||||
|
||||
var comments []*github.PullRequestComment
|
||||
|
||||
for _, resp := range hunspellParsedResp {
|
||||
prLine := linerResp.GetDiffLine(*file, resp.Line)
|
||||
|
||||
@ -33,21 +35,21 @@ func main() {
|
||||
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,
|
||||
CommitID: commit,
|
||||
Path: file,
|
||||
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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user