1
1
mirror of https://github.com/cooperspencer/gickup synced 2024-10-18 07:38:08 +02:00

added cloning of gists (#274)

This commit is contained in:
Andreas Wachter 2024-09-28 15:48:20 +02:00 committed by GitHub
parent 9e1217eef1
commit dea1d8cac2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 1 deletions

@ -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