[mirror] Command-line application for uploading a site to a git-pages server

Bail out if the Server header does not indicate git-pages.

authored by

miyuko and committed by whitequark.org ab5cefab 5c7b021f

+11
+11
main.go
··· 14 14 "net/http" 15 15 "net/url" 16 16 "os" 17 + "regexp" 17 18 "runtime/debug" 18 19 "strconv" 19 20 "strings" ··· 372 373 response, err := http.DefaultClient.Do(request) 373 374 if err != nil { 374 375 fmt.Fprintf(os.Stderr, "error: %s\n", err) 376 + os.Exit(1) 377 + } 378 + serverIdent := strings.Join(response.Header.Values("Server"), ", ") 379 + //lint:ignore SA6000 This isn't a hot loop. 380 + if matched, err := regexp.MatchString(`\bgit-pages\b`, serverIdent); err != nil { 381 + panic(err) 382 + } else if !matched { 383 + fmt.Fprintf(os.Stderr, 384 + "error: the tool only works with git-pages, but the URL points to a %q server\n", 385 + serverIdent) 375 386 os.Exit(1) 376 387 } 377 388 if displayServer {