cooperspencer / gickup

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

Ability to include/exclude on destination or have more than one source/destination pair #113

Closed thehedgefrog closed 1 year ago

thehedgefrog commented 1 year ago

I use Gickup to make a local backup of a lot of repos, including everything I have starred. I would like to copy some of those to my local Gitea, but there isn't a need for me to copy all of them to Gitea for various reasons, one of which being disk space usage.

I would like there to be an option to accomodate this workflow rather than running multiple instances of Gickup, I thought of two approaches:

I feel like both of those could bring significant improvements to Gickup, but I think the second one could bring more flexibility.

cooperspencer commented 1 year ago

Could you give an example for each option?

thehedgefrog commented 1 year ago

Of course.

Make the same include/exclude options on source available on destination:

source: 
  github:
    - token: some-token
      username: thehedgefrog
      wiki: true
      starred: true

destination:
  local:
    - path: /backups/gickup
      structured: true
  gitea:
    - token: some-token
      url: https://gitea.mydomain.com
      includeorgs:
        - thehedgefrog

Allow for more than one source/destination pair in the config file:

source: 
  github:
    - token: some-token
      username: thehedgefrog
      wiki: true
      starred: true

destination:
  local:
    - path: /backups/gickup
      structured: true

source2:
  github:
    - token: some-token
      username: thehedgefrog
      wiki: true
      includeorgs:
        - thehedgefrog

destination2:
  gitea:
    - token: some-token
      url: https://gitea.mydomain.com
cooperspencer commented 1 year ago

That might introduce some breaking changes to configuration file. It is possible to define more than one yaml structure in the same file:

source: 
  github:
    - token: some-token
      username: thehedgefrog
      wiki: true
      starred: true

destination:
  local:
    - path: /backups/gickup
      structured: true
---
source:
  github:
    - token: some-token
      username: thehedgefrog
      wiki: true
      includeorgs:
        - thehedgefrog

destination:
  gitea:
    - token: some-token
      url: https://gitea.mydomain.com

This would enable a lot of flexibility. And I could implement to load more than one config file.

thehedgefrog commented 1 year ago

It is possible to define more than one yaml structure in the same file

I think this would work well - and so would more than one config file!

cooperspencer commented 1 year ago

There is a branch called multiple_configs. can you compile that and tell me if it works for you as expected? I explained some changes in the example configuration. Basically, if there is no cron enabled in the first config, then no cron will run at all, doesn't matter if it is configured anywhere else. If cron is enabled in the first config, but a later config doesn't have a cron parameter, it will just use the one from the first config.

It is also possible to load more configuration files.

thehedgefrog commented 1 year ago

I compiled the binary and tested it, it works perfectly.

I also tested multiple config files and that also works.

cooperspencer commented 1 year ago

Awesome

Just add it at the end.

./gickup conf.yml conf2.yml

thehedgefrog commented 1 year ago

I made a typo the first time, tested it and it also works perfectly.

cooperspencer commented 1 year ago

Great, then that's a wrap. I will merge it into the main branch and create a new release.