Close #191: fork Misspell and merge 3 pending PR-s into it

This commit is contained in:
Denis Isaev 2018-08-09 20:48:36 +03:00 committed by Isaev Denis
parent 0262f00bfb
commit faa7599c95
4 changed files with 123 additions and 37 deletions

7
Gopkg.lock generated
View File

@ -30,12 +30,13 @@
version = "1.0.0"
[[projects]]
digest = "1:73dfedbcb6b348638ef0066766a9e7d8f6cfc5cfcb3a8e00ceb631a4bca73cf1"
branch = "master"
digest = "1:07d5a5772acf81583937919b21bee82377499b26d68d361b48bf8afcca1b41e5"
name = "github.com/client9/misspell"
packages = ["."]
pruneopts = "UT"
revision = "b90dc15cfd220ecf8bbc9043ecb928cef381f011"
version = "v0.3.4"
revision = "950f5d19e77066a2353d9a22e89f8f889d1d7012"
source = "github.com/golangci/misspell"
[[projects]]
digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"

View File

@ -91,3 +91,8 @@
branch = "master"
name = "honnef.co/go/tools"
source = "github.com/golangci/go-tools"
[[constraint]]
branch = "master"
name = "github.com/client9/misspell"
source = "github.com/golangci/misspell"

View File

@ -8,14 +8,18 @@ usage() {
cat <<EOF
$this: download go binaries for client9/misspell
Usage: $this [-b] bindir [version]
-b sets bindir or installation directory, default "./bin"
[version] is a version number from
Usage: $this [-b] bindir [tag]
-b sets bindir or installation directory, Defaults to ./bin
[tag] is a tag from
https://github.com/client9/misspell/releases
If version is missing, then an attempt to find the latest will be found.
If tag is missing, then an attempt to find the latest will be found.
Generated by godownloader
https://github.com/goreleaser/godownloader
Consider setting GITHUB_TOKEN to avoid triggering GitHub rate limits.
See the following for more details:
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
Generated by godownloader
https://github.com/goreleaser/godownloader
EOF
exit 2
@ -33,7 +37,7 @@ parse_args() {
esac
done
shift $((OPTIND - 1))
VERSION=$1
TAG=$1
}
# this function wraps all the destructive operations
# if a curl|bash cuts off the end of the script due to
@ -41,17 +45,16 @@ parse_args() {
# out preventing half-done work
execute() {
TMPDIR=$(mktmpdir)
echo "$PREFIX: downloading ${TARBALL_URL}"
log_debug "downloading tarball ${TARBALL_URL}"
http_download "${TMPDIR}/${TARBALL}" "${TARBALL_URL}"
echo "$PREFIX: verifying checksums"
log_debug "downloading checksum ${CHECKSUM_URL}"
http_download "${TMPDIR}/${CHECKSUM}" "${CHECKSUM_URL}"
hash_sha256_verify "${TMPDIR}/${TARBALL}" "${TMPDIR}/${CHECKSUM}"
(cd "${TMPDIR}" && untar "${TARBALL}")
install -d "${BINDIR}"
install "${TMPDIR}/${BINARY}" "${BINDIR}/"
echo "$PREFIX: installed as ${BINDIR}/${BINARY}"
log_info "installed as ${BINDIR}/${BINARY}"
}
is_supported_platform() {
platform=$1
@ -59,9 +62,11 @@ is_supported_platform() {
case "$platform" in
darwin/amd64) found=0 ;;
linux/amd64) found=0 ;;
windows/amd64) found=0 ;;
esac
case "$platform" in
darwin/386) found=1 ;;
windows/386) found=1 ;;
esac
return $found
}
@ -70,17 +75,17 @@ check_platform() {
# optional logging goes here
true
else
echo "${PREFIX}: platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
exit 1
fi
}
adjust_version() {
if [ -z "${VERSION}" ]; then
echo "$PREFIX: checking GitHub for latest version"
VERSION=$(github_last_release "$OWNER/$REPO")
tag_to_version() {
if [ -z "${TAG}" ]; then
log_info "checking GitHub for latest tag"
TAG=$(github_last_release "$OWNER/$REPO")
fi
# if version starts with 'v', remove it
VERSION=${VERSION#v}
VERSION=${TAG#v}
}
adjust_format() {
# change format (tar.gz or zip) based on ARCH
@ -116,8 +121,40 @@ EOF
is_command() {
command -v "$1" >/dev/null
}
echoerr() {
echo "$@" 1>&2
}
log_prefix() {
echo "$0"
}
_logp=6
log_set_priority() {
_logp="$1"
}
log_priority() {
if test -z "$1"; then
echo "$_logp"
return
fi
[ "$1" -ge "$_logp" ]
}
log_debug() {
log_priority 7 && echoerr "$(log_prefix)" "DEBUG" "$@"
}
log_info() {
log_priority 6 && echoerr "$(log_prefix)" "INFO" "$@"
}
log_err() {
log_priority 3 && echoerr "$(log_prefix)" "ERR" "$@"
}
log_crit() {
log_priority 2 && echoerr "$(log_prefix)" "CRIT" "$@"
}
uname_os() {
os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$os" in
msys_nt) os="windows" ;;
esac
echo "$os"
}
uname_arch() {
@ -149,7 +186,7 @@ uname_os_check() {
solaris) return 0 ;;
windows) return 0 ;;
esac
echo "$0: uname_os_check: internal error '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib"
log_crit "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib"
return 1
}
uname_arch_check() {
@ -170,7 +207,7 @@ uname_arch_check() {
s390x) return 0 ;;
amd64p32) return 0 ;;
esac
echo "$0: uname_arch_check: internal error '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib"
log_crit "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib"
return 1
}
untar() {
@ -180,7 +217,7 @@ untar() {
*.tar) tar -xf "${tarball}" ;;
*.zip) unzip "${tarball}" ;;
*)
echo "Unknown archive format for ${tarball}"
log_err "untar unknown archive format for ${tarball}"
return 1
;;
esac
@ -205,7 +242,7 @@ http_download() {
destflag='-O'
headerflag='--header'
else
echo "http_download: unable to find wget or curl"
log_crit "http_download unable to find wget or curl"
return 1
fi
if [ -z "$header" ]; then
@ -227,9 +264,11 @@ github_api() {
}
github_last_release() {
owner_repo=$1
giturl="https://api.github.com/repos/${owner_repo}/releases/latest"
html=$(github_api - "$giturl")
version=$(echo "$html" | grep -m 1 "\"tag_name\":" | cut -f4 -d'"')
version=$2
test -z "$version" && version="latest"
giturl="https://github.com/${owner_repo}/releases/${version}"
json=$(http_download "-" "$giturl" "Accept:application/json")
version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//')
test -z "$version" && return 1
echo "$version"
}
@ -248,7 +287,7 @@ hash_sha256() {
hash=$(openssl -dst openssl dgst -sha256 "$TARGET") || return 1
echo "$hash" | cut -d ' ' -f a
else
echo "hash_sha256: unable to find command to compute sha-256 hash"
log_crit "hash_sha256 unable to find command to compute sha-256 hash"
return 1
fi
}
@ -256,18 +295,18 @@ hash_sha256_verify() {
TARGET=$1
checksums=$2
if [ -z "$checksums" ]; then
echo "hash_sha256_verify: checksum file not specified in arg2"
log_err "hash_sha256_verify checksum file not specified in arg2"
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2>/dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
if [ -z "$want" ]; then
echo "hash_sha256_verify: unable to find checksum for '${TARGET}' in '${checksums}'"
log_err "hash_sha256_verify unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
fi
got=$(hash_sha256 "$TARGET")
if [ "$want" != "$got" ]; then
echo "hash_sha256_verify: checksum for '$TARGET' did not verify ${want} vs $got"
log_err "hash_sha256_verify checksum for '$TARGET' did not verify ${want} vs $got"
return 1
fi
}
@ -278,12 +317,17 @@ End of functions from https://github.com/client9/shlib
EOF
OWNER=client9
REPO=misspell
REPO="misspell"
BINARY=misspell
FORMAT=tar.gz
OS=$(uname_os)
ARCH=$(uname_arch)
PREFIX="$OWNER/$REPO"
# use in logging routines
log_prefix() {
echo "$PREFIX"
}
PLATFORM="${OS}/${ARCH}"
GITHUB_DOWNLOAD=https://github.com/${OWNER}/${REPO}/releases/download
@ -294,7 +338,7 @@ parse_args "$@"
check_platform
adjust_version
tag_to_version
adjust_format
@ -302,13 +346,13 @@ adjust_os
adjust_arch
echo "$PREFIX: found version ${VERSION} for ${OS}/${ARCH}"
log_info "found version: ${VERSION} for ${TAG}/${OS}/${ARCH}"
NAME=${BINARY}_${VERSION}_${OS}_${ARCH}
TARBALL=${NAME}.${FORMAT}
TARBALL_URL=${GITHUB_DOWNLOAD}/v${VERSION}/${TARBALL}
CHECKSUM=${REPO}_checksums.txt
CHECKSUM_URL=${GITHUB_DOWNLOAD}/v${VERSION}/${CHECKSUM}
TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
CHECKSUM=${BINARY}_${VERSION}_checksums.txt
CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}
# Adjust binary name if windows
if [ "$OS" = "windows" ]; then

View File

@ -591,6 +591,7 @@ var DictMain = []string{
"competitioners", "competitions",
"comphrehensive", "comprehensive",
"computationnal", "computational",
"concatentation", "concatenation",
"conciderations", "considerations",
"condescenscion", "condescension",
"condradictions", "contradictions",
@ -1321,6 +1322,7 @@ var DictMain = []string{
"conecntration", "concentrations",
"conenctration", "concentrations",
"confidentally", "confidentially",
"configrations", "configurations",
"configruation", "configurations",
"configuartion", "configuration",
"configuracion", "configuration",
@ -3612,6 +3614,7 @@ var DictMain = []string{
"environmentl", "environmentally",
"environmetal", "environmental",
"envrionments", "environments",
"errorneously", "erroneously",
"establishmet", "establishments",
"evelutionary", "evolutionary",
"exagerrating", "exaggerating",
@ -5913,6 +5916,7 @@ var DictMain = []string{
"attributred", "attributed",
"attributted", "attribute",
"attrocities", "atrocities",
"atttributes", "attributes",
"audiobookas", "audiobooks",
"audioboooks", "audiobook",
"auotcorrect", "autocorrect",
@ -8053,6 +8057,7 @@ var DictMain = []string{
"invincinble", "invincible",
"invisibiity", "invisibility",
"invisibiliy", "invisibility",
"invokations", "invocations",
"involantary", "involuntary",
"involentary", "involuntary",
"involintary", "involuntary",
@ -8537,6 +8542,7 @@ var DictMain = []string{
"opprotunity", "opportunity",
"optimisitic", "optimistic",
"optimizaton", "optimization",
"optmization", "optimization",
"orchestraed", "orchestrated",
"orchestrial", "orchestra",
"oreintation", "orientation",
@ -10745,6 +10751,7 @@ var DictMain = []string{
"assersions", "assertions",
"assesement", "assessment",
"assestment", "assessment",
"assigments", "assignments",
"assignemnt", "assignment",
"assimalate", "assimilate",
"assimilant", "assimilate",
@ -14366,6 +14373,7 @@ var DictMain = []string{
"omnisicent", "omniscient",
"omniverous", "omnivorous",
"omnsicient", "omniscient",
"on-premise", "on-premises",
"onmipotent", "omnipotent",
"onmiscient", "omniscient",
"operatings", "operations",
@ -17362,6 +17370,7 @@ var DictMain = []string{
"commiteed", "commited",
"commiting", "committing",
"commitmet", "commitments",
"commments", "comments",
"commongly", "commonly",
"communiss", "communists",
"communite", "communities",
@ -17456,6 +17465,7 @@ var DictMain = []string{
"construcs", "constructs",
"construde", "construed",
"construst", "constructs",
"constucts", "constructs",
"constured", "construed",
"consulant", "consultant",
"consultat", "consultant",
@ -17643,6 +17653,7 @@ var DictMain = []string{
"delcining", "declining",
"delegatie", "delegate",
"delerious", "delirious",
"deleteing", "deleting",
"delfation", "deflation",
"deliveres", "delivers",
"deliverys", "delivers",
@ -17746,6 +17757,7 @@ var DictMain = []string{
"direcotry", "directory",
"directoty", "directory",
"directroy", "directory",
"disapears", "disappears",
"disaprity", "disparity",
"disastros", "disastrous",
"disatrous", "disastrous",
@ -17898,6 +17910,7 @@ var DictMain = []string{
"enclsoure", "enclosure",
"encolsure", "enclosure",
"encompase", "encompass",
"enconding", "encoding",
"encounted", "encountered",
"encrpyted", "encrypted",
"encrytped", "encrypted",
@ -18359,6 +18372,7 @@ var DictMain = []string{
"icongnito", "incognito",
"idealisim", "idealism",
"idealistc", "idealistic",
"identifer", "identifier",
"identifiy", "identify",
"ideologis", "ideologies",
"ignornace", "ignorance",
@ -18530,6 +18544,7 @@ var DictMain = []string{
"intesnely", "intensely",
"intesnity", "intensity",
"intestins", "intestines",
"intialize", "initialize",
"inticrate", "intricate",
"intimidad", "intimidated",
"intircate", "intricate",
@ -18851,6 +18866,7 @@ var DictMain = []string{
"monstorus", "monstrous",
"monstruos", "monstrous",
"montanous", "mountainous",
"montoring", "monitoring",
"monumnets", "monuments",
"moratlity", "mortality",
"morbidley", "morbidly",
@ -19658,6 +19674,7 @@ var DictMain = []string{
"reteriver", "retriever",
"retirever", "retriever",
"retrevier", "retriever",
"retriving", "retrieving",
"reuptable", "reputable",
"reveiwers", "reviewers",
"revelaing", "revealing",
@ -21346,6 +21363,7 @@ var DictMain = []string{
"contracr", "contractor",
"contracs", "contracts",
"controll", "control",
"contruct", "construct",
"convenit", "convenient",
"convento", "convention",
"converst", "converts",
@ -21455,6 +21473,7 @@ var DictMain = []string{
"daugther", "daughter",
"deadlfit", "deadlift",
"deadlifs", "deadlifts",
"deafauts", "defaults",
"deafeted", "defeated",
"deafults", "defaults",
"dealying", "delaying",
@ -22654,6 +22673,7 @@ var DictMain = []string{
"lithuana", "lithuania",
"litigato", "litigation",
"liverpol", "liverpool",
"locagion", "location",
"logtiech", "logitech",
"longitme", "longtime",
"longtiem", "longtime",
@ -23875,6 +23895,7 @@ var DictMain = []string{
"serentiy", "serenity",
"sergaent", "sergeant",
"settigns", "settings",
"settting", "setting",
"seventen", "seventeen",
"severeal", "several",
"severeid", "severed",
@ -24209,6 +24230,7 @@ var DictMain = []string{
"supirsed", "suprised",
"suposing", "supposing",
"supporre", "supporters",
"suppoted", "supported",
"suprised", "surprised",
"suprized", "surprised",
"suprsied", "suprised",
@ -25189,6 +25211,7 @@ var DictMain = []string{
"chispet", "chipset",
"chivaly", "chivalry",
"chlesea", "chelsea",
"chnages", "changes",
"choatic", "chaotic",
"chocies", "choices",
"choosen", "chosen",
@ -25649,6 +25672,7 @@ var DictMain = []string{
"expolit", "exploit",
"exposse", "exposes",
"expries", "expires",
"exracts", "extracts",
"exsited", "existed",
"extered", "exerted",
"exterme", "extreme",
@ -25948,6 +25972,7 @@ var DictMain = []string{
"incldue", "include",
"incluse", "includes",
"indains", "indians",
"indeces", "indices",
"indiaan", "indiana",
"indluge", "indulge",
"indugle", "indulge",
@ -26490,6 +26515,7 @@ var DictMain = []string{
"posions", "poisons",
"positon", "position",
"positve", "positive",
"possibe", "possible",
"possiby", "possibly",
"postdam", "potsdam",
"postion", "position",
@ -26697,6 +26723,7 @@ var DictMain = []string{
"repalys", "replays",
"repblic", "republic",
"repeast", "repeats",
"repects", "respects",
"repitle", "reptile",
"replase", "replaces",
"replayd", "replayed",
@ -26720,6 +26747,7 @@ var DictMain = []string{
"reslove", "resolve",
"resolvs", "resolves",
"resonet", "resonate",
"resouce", "resource",
"resovle", "resolve",
"respest", "respects",
"respone", "response",
@ -26728,6 +26756,7 @@ var DictMain = []string{
"restord", "restored",
"resuced", "rescued",
"resuces", "rescues",
"retrive", "retrieve",
"returnd", "returned",
"reuinon", "reunion",
"reveald", "revealed",
@ -27467,6 +27496,7 @@ var DictMain = []string{
"coform", "conform",
"comany", "company",
"coucil", "council",
"curent", "current",
"densly", "densely",
"deside", "decide",
"devels", "delves",
@ -27506,6 +27536,7 @@ var DictMain = []string{
"fufill", "fulfill",
"futher", "further",
"gardai", "gardaí",
"geting", "getting",
"ghandi", "gandhi",
"glight", "flight",
"gloabl", "global",
@ -27534,6 +27565,7 @@ var DictMain = []string{
"inital", "initial",
"interm", "interim",
"intial", "initial",
"invlid", "invalid",
"iunior", "junior",
"jaques", "jacques",
"jospeh", "joseph",
@ -27643,8 +27675,10 @@ var DictMain = []string{
"shreak", "shriek",
"siezed", "seized",
"sixtin", "sistine",
"skiped", "skipped",
"sneeks", "sneaks",
"somene", "someone",
"soruce", "source",
"soudns", "sounds",
"sourth", "south",
"speach", "speech",
@ -27688,6 +27722,8 @@ var DictMain = []string{
"tyrany", "tyranny",
"unabel", "unable",
"unkown", "unknown",
"unmont", "unmount",
"unmout", "unmount",
"untill", "until",
"usally", "usually",
"useage", "usage",