Skip to content

Commit

Permalink
added cloning of gists
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer committed Sep 28, 2024
1 parent 9e1217e commit db1432b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions conf.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package github

import (
"context"
"fmt"
"net/http"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -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("[email protected]:%s.git", gist.GetID()),
Token: token,
Defaultbranch: "",
Origin: repo,
Owner: gist.GetOwner().GetLogin(),
Hoster: "github.com",
Description: gist.GetDescription(),
Private: !gist.GetPublic(),
})
}

i++
}
}
}

Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ type GenRepo struct {
MirrorInterval string `yaml:"mirrorinterval"`
LFS bool `yaml:"lfs"`
Mirror Mirror `yaml:"mirror"`
Gists bool `yaml:"gist"`
}

// Mirror struct
Expand Down

0 comments on commit db1432b

Please sign in to comment.