mirror of
https://github.com/cooperspencer/gickup.git
synced 2025-05-10 17:25:34 +02:00
added cloning of gists (#274)
This commit is contained in:
parent
9e1217eef1
commit
dea1d8cac2
4 changed files with 40 additions and 1 deletions
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
|
@ -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/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue