diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index eeef634..2711065 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -33,7 +33,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload a Build Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: gickup path: dist/* diff --git a/conf.example.yml b/conf.example.yml index 3341576..f66cffd 100644 --- a/conf.example.yml +++ b/conf.example.yml @@ -35,6 +35,7 @@ source: - go - java excludeforks: true # exclude forked repositories + gists: true # clone gists too gitea: - token: some-token # token_file: token.txt # alternatively, specify token in a file diff --git a/github/github.go b/github/github.go index 560b201..cf9ddb0 100644 --- a/github/github.go +++ b/github/github.go @@ -2,7 +2,9 @@ package github import ( "context" + "fmt" "net/http" + "os" "strconv" "strings" "time" @@ -322,6 +324,41 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { } } } + + } + if repo.Gists { + gistlistoptions := &github.GistListOptions{ListOptions: github.ListOptions{PerPage: 50}} + i := 1 + for { + gistlistoptions.Page = i + gists, _, err := client.Gists.List(context.Background(), repo.User, gistlistoptions) + if err != nil { + sub.Error(). + Msg(err.Error()) + continue + } + if len(gists) == 0 { + break + } + + for _, gist := range gists { + sub.Debug().Msg(gist.GetHTMLURL()) + repos = append(repos, types.Repo{ + Name: fmt.Sprintf("gists%c%s", os.PathSeparator, gist.GetID()), + URL: gist.GetHTMLURL(), + SSHURL: fmt.Sprintf("git@gist.github.com:%s.git", gist.GetID()), + Token: token, + Defaultbranch: "", + Origin: repo, + Owner: gist.GetOwner().GetLogin(), + Hoster: "github.com", + Description: gist.GetDescription(), + Private: !gist.GetPublic(), + }) + } + + i++ + } } } diff --git a/types/types.go b/types/types.go index 401a37e..e2cd2e8 100644 --- a/types/types.go +++ b/types/types.go @@ -254,6 +254,7 @@ type GenRepo struct { MirrorInterval string `yaml:"mirrorinterval"` LFS bool `yaml:"lfs"` Mirror Mirror `yaml:"mirror"` + Gists bool `yaml:"gists"` } // Mirror struct