Skip to content

Commit

Permalink
Merge pull request #11 from ypetya/master
Browse files Browse the repository at this point in the history
ISSUE-9 Add support for branch "main"
  • Loading branch information
umutphp committed Sep 10, 2020
2 parents 62efb23 + 33b75c1 commit d01dc22
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions internal/package/fetcher/fetcher.go
Expand Up @@ -12,10 +12,20 @@ import (
"time"
)

const AWESOMEREPOURL = "https://github.com/sindresorhus/awesome/"
const AWESOMEREPOURL = "https://github.com/sindresorhus/awesome"
const AWESOMECACHEFOLDER = ".awesomecache"
const RAWGITHUBUSERCONTENT = "https://raw.githubusercontent.com"

var BRANCHES = []string{"/master/", "/main/"}
var README_PATTERNS = []string{
"README",
"README.MD",
"README.md",
"readme",
"readme.md",
"readme.MD",
}

func FetchAwsomeRootRepo() (string, error) {
return FetchAwsomeRepo(AWESOMEREPOURL)
}
Expand Down Expand Up @@ -53,9 +63,8 @@ func FetchAwsomeRepo(repourl string) (string, error) {
continue
}

defer response.Body.Close()

responseData, err := ioutil.ReadAll(response.Body)
response.Body.Close()

if err != nil {
log.Println(err)
Expand All @@ -81,16 +90,17 @@ func GetPossibleReadmeFileURLs(repourl string) []string {
return []string{}
}

prefix := RAWGITHUBUSERCONTENT + u.Path + "/master/"
prefix := RAWGITHUBUSERCONTENT + u.Path

return []string{
prefix + "README",
prefix + "README.MD",
prefix + "README.md",
prefix + "readme",
prefix + "readme.md",
prefix + "readme.MD",
var ret []string

for _, br := range BRANCHES {
for _, readme := range README_PATTERNS {
ret = append(ret, prefix+br+readme)
}
}

return ret
}

func GetCachePath(url string) string {
Expand Down

0 comments on commit d01dc22

Please sign in to comment.