Skip to content

Commit 96ffbae

Browse files
authored
GitHub: Refactor GitHub user data download code (#65)
- Refactoring of the GitHub user data download code (including org migrations) - Add tests for coverage - Cleanup - remove unused travis CI files - Add GitHub action for CI on Linux, MacOS and Windows - Remove appveyor CI
1 parent 2c7432c commit 96ffbae

16 files changed

+545
-182
lines changed

.github/FUNDING.yml

-3
This file was deleted.

.github/workflows/ci.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ master ]
5+
pull_request:
6+
# The branches below must be a subset of the branches above
7+
branches: [ master ]
8+
9+
jobs:
10+
linux_tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
go: [ '1.16', '1.17' ]
15+
name: Go ${{ matrix.go }} tests - Linux
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-go@v2
19+
with:
20+
go-version: ${{ matrix.go }}
21+
- run: go test
22+
23+
macos_tests:
24+
runs-on: macOS-latest
25+
strategy:
26+
matrix:
27+
go: [ '1.16', '1.17' ]
28+
name: Go ${{ matrix.go }} tests - MacOS
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: actions/setup-go@v2
32+
with:
33+
go-version: ${{ matrix.go }}
34+
- run: go test
35+
36+
windows_tests:
37+
runs-on: windows-latest
38+
strategy:
39+
matrix:
40+
go: [ '1.16', '1.17' ]
41+
name: Go ${{ matrix.go }} tests - Windows
42+
steps:
43+
- uses: actions/checkout@v2
44+
- uses: actions/setup-go@v2
45+
with:
46+
go-version: ${{ matrix.go }}
47+
- run: go test
48+

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
language: [ 'go', 'python' ]
31+
language: [ 'go']
3232
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
3333
# Learn more:
3434
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

.github/workflows/goreleaser.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: Set up Go
2222
uses: actions/setup-go@v2
2323
with:
24-
go-version: 1.15
24+
go-version: 1.17
2525
-
2626
name: Run GoReleaser
2727
uses: goreleaser/goreleaser-action@v2

.travis.yml

-25
This file was deleted.

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
# gitbackup - Backup your GitHub, GitLab, and Bitbucket repositories
22
Code Quality [![Go Report Card](https://goreportcard.com/badge/github.com/amitsaha/gitbackup)](https://goreportcard.com/report/github.com/amitsaha/gitbackup)
3-
Linux/Mac OS X [![Build Status](https://travis-ci.org/amitsaha/gitbackup.svg?branch=master)](https://travis-ci.org/amitsaha/gitbackup) Windows [![Build status](https://ci.appveyor.com/api/projects/status/fwki40x1havyian2/branch/master?svg=true)](https://ci.appveyor.com/project/amitsaha/gitbackup/branch/master)
3+
[![.github/workflows/ci.yml](https://github.com/amitsaha/gitbackup/actions/workflows/ci.yml/badge.svg)](https://github.com/amitsaha/gitbackup/actions/workflows/ci.yml)
4+
5+
- [gitbackup - Backup your GitHub, GitLab, and Bitbucket repositories](#gitbackup---backup-your-github-gitlab-and-bitbucket-repositories)
6+
- [Introduction](#introduction)
7+
- [Installing `gitbackup`](#installing-gitbackup)
8+
- [Using `gitbackup`](#using-gitbackup)
9+
- [GitHub Specific oAuth App Flow](#github-specific-oauth-app-flow)
10+
- [OAuth Scopes/Permissions required](#oauth-scopespermissions-required)
11+
- [Bitbucket](#bitbucket)
12+
- [GitHub](#github)
13+
- [GitLab](#gitlab)
14+
- [Security and credentials](#security-and-credentials)
15+
- [Examples](#examples)
16+
- [Backing up your GitHub repositories](#backing-up-your-github-repositories)
17+
- [Backing up your GitLab repositories](#backing-up-your-gitlab-repositories)
18+
- [GitHub Enterprise or custom GitLab installation](#github-enterprise-or-custom-gitlab-installation)
19+
- [Backing up your Bitbucket repositories](#backing-up-your-bitbucket-repositories)
20+
- [Specifying a backup location](#specifying-a-backup-location)
21+
- [Cloning bare repositories](#cloning-bare-repositories)
22+
- [GitHub Migrations](#github-migrations)
23+
- [Building](#building)
24+
25+
## Introduction
426

527
``gitbackup`` is a tool to backup your git repositories from GitHub (including GitHub enterprise),
628
GitLab (including custom GitLab installations), or Bitbucket.

VERSION

-1
This file was deleted.

appveyor.yml

-22
This file was deleted.

build-binaries.bash

-12
This file was deleted.

build-binaries.py

-26
This file was deleted.

check_test.bash

-9
This file was deleted.

main.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"log"
88
"net/url"
99
"sync"
10+
"time"
1011

1112
"github.com/google/go-github/v34/github"
1213
)
@@ -122,15 +123,19 @@ func main() {
122123
}
123124

124125
if *githubWaitForMigrationComplete {
125-
downloadGithubUserMigrationData(client, *backupDir, m.ID)
126+
migrationStatePollingDuration := 60 * time.Second
127+
err = downloadGithubUserMigrationData(context.Background(), client, *backupDir, m.ID, migrationStatePollingDuration)
128+
if err != nil {
129+
log.Fatalf("Error querying/downloading migration: %v", err)
130+
}
126131
}
127132

128-
orgs, err := getUserOwnedOrgs(client)
133+
orgs, err := getGithubUserOwnedOrgs(context.Background(), client)
129134
if err != nil {
130135
log.Fatal("Error getting user organizations", err)
131136
}
132137
for _, o := range orgs {
133-
orgRepos, err := getGithubOrgRepositories(client, o)
138+
orgRepos, err := getGithubOrgRepositories(context.Background(), client, o)
134139
if err != nil {
135140
log.Fatal("Error getting org repos", err)
136141
}
@@ -144,7 +149,8 @@ func main() {
144149
log.Fatalf("Error creating migration: %v", err)
145150
}
146151
if *githubWaitForMigrationComplete {
147-
downloadGithubOrgMigrationData(client, *o.Login, *backupDir, oMigration.ID)
152+
migrationStatePollingDuration := 60 * time.Second
153+
downloadGithubOrgMigrationData(context.Background(), client, *o.Login, *backupDir, oMigration.ID, migrationStatePollingDuration)
148154
}
149155
}
150156

release.bash

-7
This file was deleted.

0 commit comments

Comments
 (0)