summaryrefslogtreecommitdiffstats
path: root/build/generate-gitignores.go
diff options
context:
space:
mode:
Diffstat (limited to 'build/generate-gitignores.go')
-rw-r--r--build/generate-gitignores.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/build/generate-gitignores.go b/build/generate-gitignores.go
index f341c1ec48..846bb07636 100644
--- a/build/generate-gitignores.go
+++ b/build/generate-gitignores.go
@@ -21,12 +21,16 @@ import (
func main() {
var (
- prefix = "gitea-gitignore"
- url = "https://api.github.com/repos/github/gitignore/tarball"
- destination = ""
+ prefix = "gitea-gitignore"
+ url = "https://api.github.com/repos/github/gitignore/tarball"
+ githubApiToken = ""
+ githubUsername = ""
+ destination = ""
)
flag.StringVar(&destination, "dest", "options/gitignore/", "destination for the gitignores")
+ flag.StringVar(&githubUsername, "username", "", "github username")
+ flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()
file, err := ioutil.TempFile(os.TempDir(), prefix)
@@ -37,12 +41,19 @@ func main() {
defer util.Remove(file.Name())
- resp, err := http.Get(url)
-
+ req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
+ if len(githubApiToken) > 0 && len(githubUsername) > 0 {
+ req.SetBasicAuth(githubUsername, githubApiToken)
+ }
+
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ log.Fatalf("Failed to download archive. %s", err)
+ }
defer resp.Body.Close()
if _, err := io.Copy(file, resp.Body); err != nil {