cooperspencer / gickup

https://cooperspencer.github.io/gickup-documentation/
Apache License 2.0
964 stars 34 forks source link

Clone GitLab Wiki repos only if they exist #78

Closed colindean closed 1 year ago

colindean commented 2 years ago

c1669ad8b508f963aa07485089973d3b458ee565 added GitLab Wiki support but it doesn't check if the repo status before cloning it, only if it's enabled or not. Because wiki is enabled by default, this results in a ton of extra work and warnings in the logs for repos that are empty:

2021-12-29T13:42:18-05:00 WRN remote repository is empty path="C:\\Users\\cad\\Source\\gickup\\tmp\\backups" stage=locally

I see this for basically every GitLab repo.

cooperspencer commented 2 years ago

The problem is that I have no idea how to check if a wiki is used or not.

cooperspencer commented 2 years ago

We could adapt the clone error like this:

if strings.Contains(err.Error(), "remote repository is empty") {
    if !strings.HasSuffix(repo.Url, ".wiki.git") || !strings.HasSuffix(repo.Url, ".wiki.git") {
        log.Warn().Str("stage", "locally").Str("path", l.Path).Str("repo", repo.Name).Msg(err.Error())
        break
    }
}
colindean commented 2 years ago

It looks like there's a Project Wikis API.

https://docs.gitlab.com/ee/api/wikis.html

Perhaps list the wiki pages without content and if it's non-zero, then clone.

cooperspencer commented 2 years ago

I'll have a look at it.

cooperspencer commented 2 years ago

I implemented the logic for the wiki clone for github and gitlab. They only clone the wiki if it has pages. eb3704b272cc08a421353cf863148c48849a5f16

For gitea I'll have to wait until their v1.16 release to implement that. Because with the current release version, they don't support a wiki api.