mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 08:08:02 +01:00
Compare commits
7 Commits
ff2681e196
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f9cf7ff89 | ||
|
|
899ab5fdc2 | ||
|
|
2a9d86a6bf | ||
|
|
4fd3ea9e3c | ||
|
|
041dc013f9 | ||
|
|
12802103c4 | ||
|
|
bf28b46954 |
17
CHANGES.rst
17
CHANGES.rst
@@ -1,10 +1,25 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
0.53.0 (2025-11-30)
|
||||
0.54.0 (2025-12-03)
|
||||
-------------------
|
||||
------------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Send INFO/DEBUG to stdout, WARNING/ERROR to stderr. [Rodos]
|
||||
|
||||
Fixes #182
|
||||
|
||||
Other
|
||||
~~~~~
|
||||
- Docs: update README testing section and add fetch vs pull explanation.
|
||||
[Rodos]
|
||||
|
||||
|
||||
0.53.0 (2025-11-30)
|
||||
-------------------
|
||||
|
||||
Fix
|
||||
~~~
|
||||
- Case-sensitive username filtering causing silent backup failures.
|
||||
|
||||
28
README.rst
28
README.rst
@@ -301,6 +301,8 @@ Starred gists vs starred repo behaviour
|
||||
|
||||
The starred normal repo cloning (``--all-starred``) argument stores starred repos separately to the users own repositories. However, using ``--starred-gists`` will store starred gists within the same directory as the users own gists ``--gists``. Also, all gist repo directory names are IDs not the gist's name.
|
||||
|
||||
Note: ``--starred-gists`` only retrieves starred gists for the authenticated user, not the target user, due to a GitHub API limitation.
|
||||
|
||||
|
||||
Skip existing on incomplete backups
|
||||
-----------------------------------
|
||||
@@ -308,6 +310,25 @@ Skip existing on incomplete backups
|
||||
The ``--skip-existing`` argument will skip a backup if the directory already exists, even if the backup in that directory failed (perhaps due to a blocking error). This may result in unexpected missing data in a regular backup.
|
||||
|
||||
|
||||
Updates use fetch, not pull
|
||||
---------------------------
|
||||
|
||||
When updating an existing repository backup, ``github-backup`` uses ``git fetch`` rather than ``git pull``. This is intentional - a backup tool should reliably download data without risk of failure. Using ``git pull`` would require handling merge conflicts, which adds complexity and could cause backups to fail unexpectedly.
|
||||
|
||||
With fetch, **all branches and commits are downloaded** safely into remote-tracking branches. The working directory files won't change, but your backup is complete.
|
||||
|
||||
If you look at files directly (e.g., ``cat README.md``), you'll see the old content. The new data is in the remote-tracking branches (confusingly named "remote" but stored locally). To view or use the latest files::
|
||||
|
||||
git show origin/main:README.md # view a file
|
||||
git merge origin/main # update working directory
|
||||
|
||||
All branches are backed up as remote refs (``origin/main``, ``origin/feature-branch``, etc.).
|
||||
|
||||
If you want to browse files directly without merging, consider using ``--bare`` which skips the working directory entirely - the backup is just the git data.
|
||||
|
||||
See `#269 <https://github.com/josegonzalez/python-github-backup/issues/269>`_ for more discussion.
|
||||
|
||||
|
||||
Github Backup Examples
|
||||
======================
|
||||
|
||||
@@ -357,7 +378,12 @@ A huge thanks to all the contibuters!
|
||||
Testing
|
||||
-------
|
||||
|
||||
This project currently contains no unit tests. To run linting::
|
||||
To run the test suite::
|
||||
|
||||
pip install pytest
|
||||
pytest
|
||||
|
||||
To run linting::
|
||||
|
||||
pip install flake8
|
||||
flake8 --ignore=E501
|
||||
|
||||
@@ -16,12 +16,23 @@ from github_backup.github_backup import (
|
||||
retrieve_repositories,
|
||||
)
|
||||
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s.%(msecs)03d: %(message)s",
|
||||
# INFO and DEBUG go to stdout, WARNING and above go to stderr
|
||||
log_format = logging.Formatter(
|
||||
fmt="%(asctime)s.%(msecs)03d: %(message)s",
|
||||
datefmt="%Y-%m-%dT%H:%M:%S",
|
||||
level=logging.INFO,
|
||||
)
|
||||
|
||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
stdout_handler.setLevel(logging.DEBUG)
|
||||
stdout_handler.addFilter(lambda r: r.levelno < logging.WARNING)
|
||||
stdout_handler.setFormatter(log_format)
|
||||
|
||||
stderr_handler = logging.StreamHandler(sys.stderr)
|
||||
stderr_handler.setLevel(logging.WARNING)
|
||||
stderr_handler.setFormatter(log_format)
|
||||
|
||||
logging.basicConfig(level=logging.INFO, handlers=[stdout_handler, stderr_handler])
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.53.0"
|
||||
__version__ = "0.54.0"
|
||||
|
||||
@@ -1565,16 +1565,22 @@ def retrieve_repositories(args, authenticated_user):
|
||||
repos.extend(gists)
|
||||
|
||||
if args.include_starred_gists:
|
||||
starred_gists_template = "https://{0}/gists/starred".format(
|
||||
get_github_api_host(args)
|
||||
)
|
||||
starred_gists = retrieve_data(
|
||||
args, starred_gists_template, single_request=False
|
||||
)
|
||||
# flag each repo as a starred gist for downstream processing
|
||||
for item in starred_gists:
|
||||
item.update({"is_gist": True, "is_starred": True})
|
||||
repos.extend(starred_gists)
|
||||
if not authenticated_user.get("login") or args.user.lower() != authenticated_user["login"].lower():
|
||||
logger.warning(
|
||||
"Cannot retrieve starred gists for '%s'. GitHub only allows access to the authenticated user's starred gists.",
|
||||
args.user,
|
||||
)
|
||||
else:
|
||||
starred_gists_template = "https://{0}/gists/starred".format(
|
||||
get_github_api_host(args)
|
||||
)
|
||||
starred_gists = retrieve_data(
|
||||
args, starred_gists_template, single_request=False
|
||||
)
|
||||
# flag each repo as a starred gist for downstream processing
|
||||
for item in starred_gists:
|
||||
item.update({"is_gist": True, "is_starred": True})
|
||||
repos.extend(starred_gists)
|
||||
|
||||
return repos
|
||||
|
||||
|
||||
Reference in New Issue
Block a user