githubtakeout 0.1.11__tar.gz → 0.1.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {githubtakeout-0.1.11/src/githubtakeout.egg-info → githubtakeout-0.1.13}/PKG-INFO +36 -39
- githubtakeout-0.1.13/README.md +104 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/pyproject.toml +26 -3
- {githubtakeout-0.1.11 → githubtakeout-0.1.13/src/githubtakeout.egg-info}/PKG-INFO +36 -39
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.py +43 -26
- githubtakeout-0.1.11/README.md +0 -107
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/LICENSE +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/setup.cfg +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.egg-info/SOURCES.txt +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.egg-info/dependency_links.txt +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.egg-info/entry_points.txt +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.egg-info/requires.txt +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.egg-info/top_level.txt +0 -0
- {githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/progress.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: githubtakeout
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.1.13
|
|
4
|
+
Summary: Backup and archive Git Repos and Gists from GitHub
|
|
5
5
|
Author: Corey Goldberg
|
|
6
6
|
Maintainer: Corey Goldberg
|
|
7
7
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
# githubtakeout
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Backup and archive Git Repos and Gists from GitHub
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -38,32 +38,30 @@ Dynamic: license-file
|
|
|
38
38
|
|
|
39
39
|
## About:
|
|
40
40
|
|
|
41
|
-
`githubtakeout` is a data export tool for
|
|
42
|
-
It clones a user's repos and creates an archive
|
|
41
|
+
`githubtakeout` is a data export tool for backing up and archiving Git
|
|
42
|
+
repositories hosted on GitHub. It clones a user's repos and creates an archive
|
|
43
|
+
of each.
|
|
43
44
|
|
|
44
|
-
It supports public/private repos and public/secret gists. By default, it
|
|
45
|
-
commit history or branches (`.git` directory), or Gist
|
|
46
|
-
with command line options).
|
|
45
|
+
It supports public/private repos and public/secret gists. By default, it
|
|
46
|
+
doesn't save commit history or branches (`.git` directory), or Gist
|
|
47
|
+
repositories (both can be enabled with command line options).
|
|
47
48
|
|
|
48
|
-
When you run the program, archives of your repos will be saved in a directory
|
|
49
|
-
`backups` inside your current working directory, unless a different
|
|
50
|
-
using the `--dir` option.
|
|
49
|
+
When you run the program, archives of your repos will be saved in a directory
|
|
50
|
+
named `backups` inside your current working directory, unless a different
|
|
51
|
+
location is specified using the `--dir` option.
|
|
51
52
|
|
|
52
|
-
Archives are saved in compressed zip format (`.zip`) by default
|
|
53
|
-
as tarballs (`.tar.gz`) using the `--format=tar` option
|
|
53
|
+
Archives are saved in compressed zip format (`.zip`) by default. You can also
|
|
54
|
+
save as tarballs (`.tar.gz`) using the `--format=tar` option, or skip archiving
|
|
55
|
+
using the `--format=none` option.
|
|
54
56
|
|
|
55
57
|
## Requirements:
|
|
56
58
|
|
|
57
59
|
- Python 3.12+
|
|
58
60
|
- Git 1.7+
|
|
59
|
-
- Python packages:
|
|
60
|
-
- [GitPython][pypi-gitpython]
|
|
61
|
-
- [PyGithub][pypi-pygithub]
|
|
62
|
-
- [rich][pypi-rich]
|
|
63
61
|
|
|
64
62
|
## Installation:
|
|
65
63
|
|
|
66
|
-
Install from [PyPI][
|
|
64
|
+
#### Install from [PyPI][pypi-githubtakeout]:
|
|
67
65
|
|
|
68
66
|
```
|
|
69
67
|
pip install githubtakeout
|
|
@@ -71,46 +69,49 @@ pip install githubtakeout
|
|
|
71
69
|
|
|
72
70
|
## Authentication:
|
|
73
71
|
|
|
74
|
-
By default, `githubtakeout` will only retrieve an account's public repos. To
|
|
75
|
-
you need to authenticate.
|
|
72
|
+
By default, `githubtakeout` will only retrieve an account's public repos. To
|
|
73
|
+
access private repos and secret gists, you need to authenticate.
|
|
76
74
|
|
|
77
|
-
First, you must create a [personal access token][github-pat] on Github (either
|
|
78
|
-
access token). Once you have a token, you
|
|
75
|
+
First, you must create a [personal access token][github-pat] on Github (either
|
|
76
|
+
a fine-grained or classic personal access token). Once you have a token, you
|
|
77
|
+
can set the `GITHUB_TOKEN` environment variable:
|
|
79
78
|
|
|
80
79
|
```
|
|
81
80
|
$ export GITHUB_TOKEN=<access token>
|
|
82
81
|
```
|
|
83
82
|
|
|
84
|
-
If you prefer to be prompted for your token each time you run the program, use
|
|
83
|
+
If you prefer to be prompted for your token each time you run the program, use
|
|
84
|
+
the `--token` argument.
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
## CLI Options:
|
|
87
87
|
|
|
88
88
|
```
|
|
89
|
-
usage: githubtakeout [-h] [--dir DIR] [--format {tar,zip}] [--gists] [--history] [--list] [--token] username
|
|
89
|
+
usage: githubtakeout [-h] [--dir DIR] [--pattern PATTERN] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
|
|
90
90
|
|
|
91
91
|
positional arguments:
|
|
92
|
-
username
|
|
92
|
+
username github username
|
|
93
93
|
|
|
94
94
|
options:
|
|
95
|
-
-h, --help
|
|
96
|
-
--dir DIR
|
|
97
|
-
--
|
|
98
|
-
--
|
|
99
|
-
--
|
|
100
|
-
--
|
|
101
|
-
--
|
|
95
|
+
-h, --help show this help message and exit
|
|
96
|
+
--dir DIR output directory (default: .)
|
|
97
|
+
--pattern PATTERN regex matching repo names (default: .*)
|
|
98
|
+
--format {tar,zip,none} archive format (default: zip)
|
|
99
|
+
--gists include gists
|
|
100
|
+
--history include commit history and branches (.git directory)
|
|
101
|
+
--list list repos only
|
|
102
|
+
--token prompt for auth token
|
|
102
103
|
```
|
|
103
104
|
|
|
104
105
|
## Usage Examples:
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
#### Install from PyPI with pipx, Run:
|
|
107
108
|
|
|
108
109
|
```
|
|
109
110
|
pipx install githubtakeout
|
|
110
111
|
githubtakeout <github username>
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
#### Clone Repo, Create/Activate Virtual Environment, Install from Source, Run:
|
|
114
115
|
|
|
115
116
|
```
|
|
116
117
|
git clone git@github.com:cgoldberg/githubtakeout.git
|
|
@@ -121,12 +122,8 @@ pip install .
|
|
|
121
122
|
githubtakeout <github username>
|
|
122
123
|
```
|
|
123
124
|
|
|
124
|
-
|
|
125
125
|
[github-home]: https://github.com/cgoldberg
|
|
126
126
|
[github-repo]: https://github.com/cgoldberg/sudokubot
|
|
127
127
|
[github-pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
|
|
128
128
|
[pypi-githubtakeout]: https://pypi.org/project/githubtakeout
|
|
129
|
-
[pypi-gitpython]: https://pypi.org/project/GitPython
|
|
130
|
-
[pypi-pygithub]: https://pypi.org/project/PyGithub
|
|
131
|
-
[pypi-rich]: https://pypi.org/project/rich
|
|
132
129
|
[mit-license]: https://raw.githubusercontent.com/cgoldberg/githubtakeout/refs/heads/master/LICENSE
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# githubtakeout
|
|
2
|
+
|
|
3
|
+
## Backup and archive Git Repos and Gists from GitHub
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
- Copyright (c) 2015-2025 [Corey Goldberg][github-home]
|
|
8
|
+
- Development: [GitHub][github-repo]
|
|
9
|
+
- Download/Install: [PyPI][pypi-githubtakeout]
|
|
10
|
+
- License: [MIT][mit-license]
|
|
11
|
+
|
|
12
|
+
----
|
|
13
|
+
|
|
14
|
+
## About:
|
|
15
|
+
|
|
16
|
+
`githubtakeout` is a data export tool for backing up and archiving Git
|
|
17
|
+
repositories hosted on GitHub. It clones a user's repos and creates an archive
|
|
18
|
+
of each.
|
|
19
|
+
|
|
20
|
+
It supports public/private repos and public/secret gists. By default, it
|
|
21
|
+
doesn't save commit history or branches (`.git` directory), or Gist
|
|
22
|
+
repositories (both can be enabled with command line options).
|
|
23
|
+
|
|
24
|
+
When you run the program, archives of your repos will be saved in a directory
|
|
25
|
+
named `backups` inside your current working directory, unless a different
|
|
26
|
+
location is specified using the `--dir` option.
|
|
27
|
+
|
|
28
|
+
Archives are saved in compressed zip format (`.zip`) by default. You can also
|
|
29
|
+
save as tarballs (`.tar.gz`) using the `--format=tar` option, or skip archiving
|
|
30
|
+
using the `--format=none` option.
|
|
31
|
+
|
|
32
|
+
## Requirements:
|
|
33
|
+
|
|
34
|
+
- Python 3.12+
|
|
35
|
+
- Git 1.7+
|
|
36
|
+
|
|
37
|
+
## Installation:
|
|
38
|
+
|
|
39
|
+
#### Install from [PyPI][pypi-githubtakeout]:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
pip install githubtakeout
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Authentication:
|
|
46
|
+
|
|
47
|
+
By default, `githubtakeout` will only retrieve an account's public repos. To
|
|
48
|
+
access private repos and secret gists, you need to authenticate.
|
|
49
|
+
|
|
50
|
+
First, you must create a [personal access token][github-pat] on Github (either
|
|
51
|
+
a fine-grained or classic personal access token). Once you have a token, you
|
|
52
|
+
can set the `GITHUB_TOKEN` environment variable:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
$ export GITHUB_TOKEN=<access token>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If you prefer to be prompted for your token each time you run the program, use
|
|
59
|
+
the `--token` argument.
|
|
60
|
+
|
|
61
|
+
## CLI Options:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
usage: githubtakeout [-h] [--dir DIR] [--pattern PATTERN] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
|
|
65
|
+
|
|
66
|
+
positional arguments:
|
|
67
|
+
username github username
|
|
68
|
+
|
|
69
|
+
options:
|
|
70
|
+
-h, --help show this help message and exit
|
|
71
|
+
--dir DIR output directory (default: .)
|
|
72
|
+
--pattern PATTERN regex matching repo names (default: .*)
|
|
73
|
+
--format {tar,zip,none} archive format (default: zip)
|
|
74
|
+
--gists include gists
|
|
75
|
+
--history include commit history and branches (.git directory)
|
|
76
|
+
--list list repos only
|
|
77
|
+
--token prompt for auth token
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage Examples:
|
|
81
|
+
|
|
82
|
+
#### Install from PyPI with pipx, Run:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
pipx install githubtakeout
|
|
86
|
+
githubtakeout <github username>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Clone Repo, Create/Activate Virtual Environment, Install from Source, Run:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
git clone git@github.com:cgoldberg/githubtakeout.git
|
|
93
|
+
cd ./githubtakeout
|
|
94
|
+
python3 -m venv venv
|
|
95
|
+
source venv/bin/activate
|
|
96
|
+
pip install .
|
|
97
|
+
githubtakeout <github username>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
[github-home]: https://github.com/cgoldberg
|
|
101
|
+
[github-repo]: https://github.com/cgoldberg/sudokubot
|
|
102
|
+
[github-pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
|
|
103
|
+
[pypi-githubtakeout]: https://pypi.org/project/githubtakeout
|
|
104
|
+
[mit-license]: https://raw.githubusercontent.com/cgoldberg/githubtakeout/refs/heads/master/LICENSE
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "githubtakeout"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
description = "
|
|
7
|
+
version = "0.1.13"
|
|
8
|
+
description = "Backup and archive Git Repos and Gists from GitHub"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
license-files = ["LICENSE"]
|
|
11
11
|
authors = [{name = "Corey Goldberg"}]
|
|
@@ -35,12 +35,28 @@ homepage = "https://github.com/cgoldberg/githubtakeout"
|
|
|
35
35
|
source = "https://github.com/cgoldberg/githubtakeout"
|
|
36
36
|
download = "https://pypi.org/project/githubtakeout"
|
|
37
37
|
|
|
38
|
+
[dependency-groups]
|
|
39
|
+
dev = [
|
|
40
|
+
"tox",
|
|
41
|
+
]
|
|
42
|
+
lint = [
|
|
43
|
+
"black",
|
|
44
|
+
"refurb",
|
|
45
|
+
"ruff",
|
|
46
|
+
]
|
|
47
|
+
validate = [
|
|
48
|
+
"packaging",
|
|
49
|
+
"validate-pyproject",
|
|
50
|
+
]
|
|
51
|
+
|
|
38
52
|
[tool.setuptools]
|
|
39
53
|
package-dir = {"" = "src"}
|
|
40
54
|
|
|
41
55
|
[tool.black]
|
|
42
56
|
line-length = 120
|
|
43
|
-
target-version = [
|
|
57
|
+
target-version = [
|
|
58
|
+
"py312", "py313"
|
|
59
|
+
]
|
|
44
60
|
|
|
45
61
|
[tool.ruff]
|
|
46
62
|
line-length = 120
|
|
@@ -60,3 +76,10 @@ fixable = ["ALL"]
|
|
|
60
76
|
[tool.ruff.format]
|
|
61
77
|
docstring-code-format = true
|
|
62
78
|
docstring-code-line-length = 120
|
|
79
|
+
|
|
80
|
+
[tool.refurb]
|
|
81
|
+
python_version = "3.9"
|
|
82
|
+
enable_all = true
|
|
83
|
+
disable = [
|
|
84
|
+
"FURB104", "FURB107", "FURB147", "FURB173", "FURB183", "FURB184"
|
|
85
|
+
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: githubtakeout
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.1.13
|
|
4
|
+
Summary: Backup and archive Git Repos and Gists from GitHub
|
|
5
5
|
Author: Corey Goldberg
|
|
6
6
|
Maintainer: Corey Goldberg
|
|
7
7
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
# githubtakeout
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Backup and archive Git Repos and Gists from GitHub
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -38,32 +38,30 @@ Dynamic: license-file
|
|
|
38
38
|
|
|
39
39
|
## About:
|
|
40
40
|
|
|
41
|
-
`githubtakeout` is a data export tool for
|
|
42
|
-
It clones a user's repos and creates an archive
|
|
41
|
+
`githubtakeout` is a data export tool for backing up and archiving Git
|
|
42
|
+
repositories hosted on GitHub. It clones a user's repos and creates an archive
|
|
43
|
+
of each.
|
|
43
44
|
|
|
44
|
-
It supports public/private repos and public/secret gists. By default, it
|
|
45
|
-
commit history or branches (`.git` directory), or Gist
|
|
46
|
-
with command line options).
|
|
45
|
+
It supports public/private repos and public/secret gists. By default, it
|
|
46
|
+
doesn't save commit history or branches (`.git` directory), or Gist
|
|
47
|
+
repositories (both can be enabled with command line options).
|
|
47
48
|
|
|
48
|
-
When you run the program, archives of your repos will be saved in a directory
|
|
49
|
-
`backups` inside your current working directory, unless a different
|
|
50
|
-
using the `--dir` option.
|
|
49
|
+
When you run the program, archives of your repos will be saved in a directory
|
|
50
|
+
named `backups` inside your current working directory, unless a different
|
|
51
|
+
location is specified using the `--dir` option.
|
|
51
52
|
|
|
52
|
-
Archives are saved in compressed zip format (`.zip`) by default
|
|
53
|
-
as tarballs (`.tar.gz`) using the `--format=tar` option
|
|
53
|
+
Archives are saved in compressed zip format (`.zip`) by default. You can also
|
|
54
|
+
save as tarballs (`.tar.gz`) using the `--format=tar` option, or skip archiving
|
|
55
|
+
using the `--format=none` option.
|
|
54
56
|
|
|
55
57
|
## Requirements:
|
|
56
58
|
|
|
57
59
|
- Python 3.12+
|
|
58
60
|
- Git 1.7+
|
|
59
|
-
- Python packages:
|
|
60
|
-
- [GitPython][pypi-gitpython]
|
|
61
|
-
- [PyGithub][pypi-pygithub]
|
|
62
|
-
- [rich][pypi-rich]
|
|
63
61
|
|
|
64
62
|
## Installation:
|
|
65
63
|
|
|
66
|
-
Install from [PyPI][
|
|
64
|
+
#### Install from [PyPI][pypi-githubtakeout]:
|
|
67
65
|
|
|
68
66
|
```
|
|
69
67
|
pip install githubtakeout
|
|
@@ -71,46 +69,49 @@ pip install githubtakeout
|
|
|
71
69
|
|
|
72
70
|
## Authentication:
|
|
73
71
|
|
|
74
|
-
By default, `githubtakeout` will only retrieve an account's public repos. To
|
|
75
|
-
you need to authenticate.
|
|
72
|
+
By default, `githubtakeout` will only retrieve an account's public repos. To
|
|
73
|
+
access private repos and secret gists, you need to authenticate.
|
|
76
74
|
|
|
77
|
-
First, you must create a [personal access token][github-pat] on Github (either
|
|
78
|
-
access token). Once you have a token, you
|
|
75
|
+
First, you must create a [personal access token][github-pat] on Github (either
|
|
76
|
+
a fine-grained or classic personal access token). Once you have a token, you
|
|
77
|
+
can set the `GITHUB_TOKEN` environment variable:
|
|
79
78
|
|
|
80
79
|
```
|
|
81
80
|
$ export GITHUB_TOKEN=<access token>
|
|
82
81
|
```
|
|
83
82
|
|
|
84
|
-
If you prefer to be prompted for your token each time you run the program, use
|
|
83
|
+
If you prefer to be prompted for your token each time you run the program, use
|
|
84
|
+
the `--token` argument.
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
## CLI Options:
|
|
87
87
|
|
|
88
88
|
```
|
|
89
|
-
usage: githubtakeout [-h] [--dir DIR] [--format {tar,zip}] [--gists] [--history] [--list] [--token] username
|
|
89
|
+
usage: githubtakeout [-h] [--dir DIR] [--pattern PATTERN] [--format {tar,zip,none}] [--gists] [--history] [--list] [--token] username
|
|
90
90
|
|
|
91
91
|
positional arguments:
|
|
92
|
-
username
|
|
92
|
+
username github username
|
|
93
93
|
|
|
94
94
|
options:
|
|
95
|
-
-h, --help
|
|
96
|
-
--dir DIR
|
|
97
|
-
--
|
|
98
|
-
--
|
|
99
|
-
--
|
|
100
|
-
--
|
|
101
|
-
--
|
|
95
|
+
-h, --help show this help message and exit
|
|
96
|
+
--dir DIR output directory (default: .)
|
|
97
|
+
--pattern PATTERN regex matching repo names (default: .*)
|
|
98
|
+
--format {tar,zip,none} archive format (default: zip)
|
|
99
|
+
--gists include gists
|
|
100
|
+
--history include commit history and branches (.git directory)
|
|
101
|
+
--list list repos only
|
|
102
|
+
--token prompt for auth token
|
|
102
103
|
```
|
|
103
104
|
|
|
104
105
|
## Usage Examples:
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
#### Install from PyPI with pipx, Run:
|
|
107
108
|
|
|
108
109
|
```
|
|
109
110
|
pipx install githubtakeout
|
|
110
111
|
githubtakeout <github username>
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
#### Clone Repo, Create/Activate Virtual Environment, Install from Source, Run:
|
|
114
115
|
|
|
115
116
|
```
|
|
116
117
|
git clone git@github.com:cgoldberg/githubtakeout.git
|
|
@@ -121,12 +122,8 @@ pip install .
|
|
|
121
122
|
githubtakeout <github username>
|
|
122
123
|
```
|
|
123
124
|
|
|
124
|
-
|
|
125
125
|
[github-home]: https://github.com/cgoldberg
|
|
126
126
|
[github-repo]: https://github.com/cgoldberg/sudokubot
|
|
127
127
|
[github-pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
|
|
128
128
|
[pypi-githubtakeout]: https://pypi.org/project/githubtakeout
|
|
129
|
-
[pypi-gitpython]: https://pypi.org/project/GitPython
|
|
130
|
-
[pypi-pygithub]: https://pypi.org/project/PyGithub
|
|
131
|
-
[pypi-rich]: https://pypi.org/project/rich
|
|
132
129
|
[mit-license]: https://raw.githubusercontent.com/cgoldberg/githubtakeout/refs/heads/master/LICENSE
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# Copyright (c) 2015-2025 Corey Goldberg
|
|
2
2
|
# License: MIT
|
|
3
3
|
|
|
4
|
-
"""
|
|
4
|
+
"""Backup and archive Git Repos and Gists from GitHub."""
|
|
5
5
|
|
|
6
6
|
import argparse
|
|
7
7
|
import getpass
|
|
8
8
|
import logging
|
|
9
9
|
import math
|
|
10
10
|
import os
|
|
11
|
+
import re
|
|
11
12
|
import shutil
|
|
12
13
|
import stat
|
|
13
14
|
import sys
|
|
@@ -22,7 +23,7 @@ import github
|
|
|
22
23
|
|
|
23
24
|
from progress import GitProgress
|
|
24
25
|
|
|
25
|
-
ARCHIVE_FORMATS = ("tar", "zip")
|
|
26
|
+
ARCHIVE_FORMATS = ("tar", "zip", "none")
|
|
26
27
|
|
|
27
28
|
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
|
28
29
|
logger = logging.getLogger(__name__)
|
|
@@ -52,6 +53,8 @@ def add_creds(url, username, token):
|
|
|
52
53
|
def archive(local_repo_dir, archive_format="zip", is_gist=False):
|
|
53
54
|
if archive_format not in ARCHIVE_FORMATS:
|
|
54
55
|
raise ValueError(f"{archive_format} is not a valid archive format")
|
|
56
|
+
if archive_format == "none":
|
|
57
|
+
return None
|
|
55
58
|
base_name = os.path.basename(local_repo_dir)
|
|
56
59
|
extension = "tar.gz" if archive_format == "tar" else archive_format
|
|
57
60
|
archive_name = f"{base_name}.{extension}"
|
|
@@ -132,14 +135,15 @@ def clone_and_archive_repo(repo_url, local_repo_dir, archive_format, include_his
|
|
|
132
135
|
except FileNotFoundError:
|
|
133
136
|
pass
|
|
134
137
|
archive_path = archive(local_repo_dir, archive_format, is_gist)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
if archive_path:
|
|
139
|
+
size = convert_size(os.path.getsize(archive_path))
|
|
140
|
+
logger.info(f"archive size: {size}")
|
|
141
|
+
logger.info("deleting repo")
|
|
142
|
+
try:
|
|
143
|
+
# delete repo after archive is created
|
|
144
|
+
shutil.rmtree(local_repo_dir, onexc=remove_readonly)
|
|
145
|
+
except FileNotFoundError:
|
|
146
|
+
pass
|
|
143
147
|
elapsed = default_timer() - start
|
|
144
148
|
base_name = os.path.basename(local_repo_dir)
|
|
145
149
|
logger.info(f"successfully backed up '{base_name}' repo in {elapsed:.3f} secs\n")
|
|
@@ -191,6 +195,7 @@ def get_token(prompt_for_token):
|
|
|
191
195
|
def run(
|
|
192
196
|
username,
|
|
193
197
|
base_dir,
|
|
198
|
+
pattern,
|
|
194
199
|
archive_format,
|
|
195
200
|
include_gists,
|
|
196
201
|
include_history,
|
|
@@ -200,39 +205,50 @@ def run(
|
|
|
200
205
|
working_dir = os.path.join(base_dir, "backups")
|
|
201
206
|
token = get_token(prompt_for_token)
|
|
202
207
|
repos, gists = get_repos(username, token, include_gists)
|
|
203
|
-
num_repos = repos.
|
|
208
|
+
num_repos = len([repo for repo in repos if re.match(pattern, repo.name)])
|
|
204
209
|
if not list_only:
|
|
205
210
|
logger.info(f"creating archives in: {working_dir}\n")
|
|
206
211
|
logger.info(f"found {num_repos} repos for user '{username}'\n")
|
|
207
212
|
for repo in repos:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
if re.match(pattern, repo.name):
|
|
214
|
+
local_repo_dir = os.path.join(working_dir, repo.name)
|
|
215
|
+
url = add_creds(repo.clone_url, username, token)
|
|
216
|
+
if list_only:
|
|
217
|
+
logger.info(url)
|
|
218
|
+
else:
|
|
219
|
+
clone_and_archive_repo(url, local_repo_dir, archive_format, include_history)
|
|
214
220
|
if gists is not None:
|
|
215
|
-
num_gists = gists.
|
|
221
|
+
num_gists = len([gist for gist in gists if re.match(pattern, gist.id)])
|
|
216
222
|
logger.info("")
|
|
217
223
|
logger.info(f"found {num_gists} gists for user '{username}'\n")
|
|
218
224
|
for gist in gists:
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
if re.match(pattern, gist.id):
|
|
226
|
+
local_repo_dir = os.path.join(working_dir, gist.id)
|
|
227
|
+
url = add_creds(gist.git_pull_url, username, token)
|
|
228
|
+
if list_only:
|
|
229
|
+
logger.info(url)
|
|
230
|
+
else:
|
|
231
|
+
clone_and_archive_repo(url, local_repo_dir, archive_format, include_history, is_gist=True)
|
|
225
232
|
|
|
226
233
|
|
|
227
234
|
def main():
|
|
228
235
|
if sys.version_info < (3, 12):
|
|
229
236
|
sys.exit("sorry, this program requires Python 3.12+")
|
|
230
|
-
|
|
237
|
+
|
|
238
|
+
def formatter(prog):
|
|
239
|
+
return argparse.HelpFormatter(prog, max_help_position=30)
|
|
240
|
+
|
|
241
|
+
parser = argparse.ArgumentParser(formatter_class=formatter)
|
|
231
242
|
parser.add_argument("username", help="github username")
|
|
232
243
|
parser.add_argument(
|
|
233
244
|
"--dir",
|
|
234
245
|
default=os.getcwd(),
|
|
235
|
-
help="output directory (default:
|
|
246
|
+
help="output directory (default: .)",
|
|
247
|
+
)
|
|
248
|
+
parser.add_argument(
|
|
249
|
+
"--pattern",
|
|
250
|
+
default=".*",
|
|
251
|
+
help="regex matching repo names (default: .*)",
|
|
236
252
|
)
|
|
237
253
|
parser.add_argument(
|
|
238
254
|
"--format",
|
|
@@ -254,6 +270,7 @@ def main():
|
|
|
254
270
|
run(
|
|
255
271
|
username=args.username,
|
|
256
272
|
base_dir=args.dir,
|
|
273
|
+
pattern=args.pattern,
|
|
257
274
|
archive_format=args.format,
|
|
258
275
|
include_gists=args.gists,
|
|
259
276
|
include_history=args.history,
|
githubtakeout-0.1.11/README.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# githubtakeout
|
|
2
|
-
|
|
3
|
-
## Archive Git Repos and Gists from GitHub
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
- Copyright (c) 2015-2025 [Corey Goldberg][github-home]
|
|
8
|
-
- Development: [GitHub][github-repo]
|
|
9
|
-
- Download/Install: [PyPI][pypi-githubtakeout]
|
|
10
|
-
- License: [MIT][mit-license]
|
|
11
|
-
|
|
12
|
-
----
|
|
13
|
-
|
|
14
|
-
## About:
|
|
15
|
-
|
|
16
|
-
`githubtakeout` is a data export tool for archiving Git repositories hosted on GitHub.
|
|
17
|
-
It clones a user's repos and creates an archive of each.
|
|
18
|
-
|
|
19
|
-
It supports public/private repos and public/secret gists. By default, it doesn't save
|
|
20
|
-
commit history or branches (`.git` directory), or Gist repositories (both can be enabled
|
|
21
|
-
with command line options).
|
|
22
|
-
|
|
23
|
-
When you run the program, archives of your repos will be saved in a directory named
|
|
24
|
-
`backups` inside your current working directory, unless a different location is specified
|
|
25
|
-
using the `--dir` option.
|
|
26
|
-
|
|
27
|
-
Archives are saved in compressed zip format (`.zip`) by default, but can also be saved
|
|
28
|
-
as tarballs (`.tar.gz`) using the `--format=tar` option.
|
|
29
|
-
|
|
30
|
-
## Requirements:
|
|
31
|
-
|
|
32
|
-
- Python 3.12+
|
|
33
|
-
- Git 1.7+
|
|
34
|
-
- Python packages:
|
|
35
|
-
- [GitPython][pypi-gitpython]
|
|
36
|
-
- [PyGithub][pypi-pygithub]
|
|
37
|
-
- [rich][pypi-rich]
|
|
38
|
-
|
|
39
|
-
## Installation:
|
|
40
|
-
|
|
41
|
-
Install from [PyPI][pypyi-githubtakeout]:
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
pip install githubtakeout
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Authentication:
|
|
48
|
-
|
|
49
|
-
By default, `githubtakeout` will only retrieve an account's public repos. To access private repos and secret gists,
|
|
50
|
-
you need to authenticate.
|
|
51
|
-
|
|
52
|
-
First, you must create a [personal access token][github-pat] on Github (either a fine-grained or classic personal
|
|
53
|
-
access token). Once you have a token, you can set the `GITHUB_TOKEN` environment variable:
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
$ export GITHUB_TOKEN=<access token>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
If you prefer to be prompted for your token each time you run the program, use the `--token` argument.
|
|
60
|
-
|
|
61
|
-
### CLI Options:
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
usage: githubtakeout [-h] [--dir DIR] [--format {tar,zip}] [--gists] [--history] [--list] [--token] username
|
|
65
|
-
|
|
66
|
-
positional arguments:
|
|
67
|
-
username github username
|
|
68
|
-
|
|
69
|
-
options:
|
|
70
|
-
-h, --help show this help message and exit
|
|
71
|
-
--dir DIR output directory (default: ./)
|
|
72
|
-
--format {tar,zip} archive format (default: zip)
|
|
73
|
-
--gists include gists
|
|
74
|
-
--history include commit history and branches (.git directory)
|
|
75
|
-
--list list repos only
|
|
76
|
-
--token prompt for auth token
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Usage Examples:
|
|
80
|
-
|
|
81
|
-
### Install from PyPI with pipx, Run:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
pipx install githubtakeout
|
|
85
|
-
githubtakeout <github username>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Clone Repo, Create/Activate Virtual Environment, Install from Source, Run:
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
git clone git@github.com:cgoldberg/githubtakeout.git
|
|
92
|
-
cd ./githubtakeout
|
|
93
|
-
python3 -m venv venv
|
|
94
|
-
source venv/bin/activate
|
|
95
|
-
pip install .
|
|
96
|
-
githubtakeout <github username>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
[github-home]: https://github.com/cgoldberg
|
|
101
|
-
[github-repo]: https://github.com/cgoldberg/sudokubot
|
|
102
|
-
[github-pat]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
|
|
103
|
-
[pypi-githubtakeout]: https://pypi.org/project/githubtakeout
|
|
104
|
-
[pypi-gitpython]: https://pypi.org/project/GitPython
|
|
105
|
-
[pypi-pygithub]: https://pypi.org/project/PyGithub
|
|
106
|
-
[pypi-rich]: https://pypi.org/project/rich
|
|
107
|
-
[mit-license]: https://raw.githubusercontent.com/cgoldberg/githubtakeout/refs/heads/master/LICENSE
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{githubtakeout-0.1.11 → githubtakeout-0.1.13}/src/githubtakeout.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|