ads-github-tools

Manage a large number of GitHub repos (command line tools)

View the Project on GitHub salewski/ads-github-tools

'ads-github-pages' project home page

The ads-github-tools project provides command line tools for managing a large number of GitHub repositories, motivated by the following two related use cases:

  1. When you work on multiple computers, keeping your local clones of the repos in synch can be a chore.

  2. Similarly, when you have a large number of GitHub repos that are mostly forks of other repos, keeping your forks in synch with the upstream changes can be a chore.

Enter the ads-github-tools.

Usage

Typical usage involves ensuring there is an updated cache, and then just invoking a couple of commands.

The cache is updated like this:

    $ ads-github-cache -v --update

First time users will want to update the cache prior to running any of the other commands. It may take a while to poplute the cache the first time (especially if you have a large number of GitHub repos), but updating it thereafer is done conditionally and on an as-needed basis. Note that the only objects cached are those used by the various utilities in the ads-github-tools; it does not cache any data that is not used.

The cache is provided in order to avoid unnecessary network round trips to the GitHub API servers and allow the utilities to work quickly in an interactive shell process. The cache storage is specific to each GitHub user. A Unix system user may have multiple GitHub accounts (say, work and personal); the cached data for those GitHub users would be stored separately.

Regular users would probably just run the above cache update command (say, once or twice a day) from a cron job (or similar). That way the cached data is already available when you need it.

With the cached data in hand, you're ready to run the other utilities. Typical invocation involves only one or two commands, both invoked from the parent directory of the user's directory that contains his GitHub projects (forked and otherwise). The 'ads-github-tools' author typcially runs these two commands once or twice daily:

    $ ads-github-fetch-all-upstreams -v -c

    $ ads-github-merge-all-upstreams -v -k -p

Many users would prefer to run those commands from a crontab (or similar); the author runs them manually because he is actively hacking on the tools and wants to inspect the output.

The following invocation is also handy for creating local clones of recently forked GitHub repos:

    $ ads-github-fetch-all-upstreams -m

That will clone all of a user's GitHub repos for which there is no working directory beneath the current directory. It can be thought of as creating clones of "all the new stuff (and just the new stuff)"; it operates much more quickly than invocations that operate on all of a user's GitHub repos (assuming only a minority of them are "missing", which is the common case). Note that the '-m' (--missing-only) option was introduced in the version of 'ads-github-fetch-all-upstreams' released with ads-github-tools-0.2.0 (circa 2017).

Installation

Installation should be as simple as:

    $ ./configure   # add a --prefix=path/to/some/location to install someplace other than beneath /usr/local
    $ make
    $ make check    # optional, but encouraged
    $ make install

Progams provided by ads-github-tools

At the time of writing (2022-10-26) there are ten tools:

Future directions

The ads-github-tools-0.3.2 release (October 2020) introduced the foundations for the long-wanted caching system. It delivers on the ability to conditionally retrieve objects "through the cache" using 'ETag:' and 'If-None-Match:' to pull full objects over the network only when necessary. It also delivers on the goal of being easy to use from shell scripts or even in an interactive shell.

Note that conditionally fetching objects as described also has the benefit of avoiding incurring unnecessary hits against the user's GitHub API rate limit. (Not sure where you stand? Try 'ads-github-show-rate-limits -h' to find out!)

At the moment, the caching foundation is in place, and the ads-github-fetch-all-upstreams tool uses it to good effect. But currently it is the only tool that does so. Others will be enhanced, as well, in upcoming releases.

My earlier thinking was that there will be three levels of tools:

  1. low-level tools that store and retrieve objects from the cache, and related

    • 'ads-github-cache update' (similar in spirit to 'apt-get update' and 'apt-file update')
    • 'ads-github-cache put KEY [VALUE]'
    • 'ads-github-cache get KEY'
    • 'ads-github-normalize-url'>
    • 'ads-github-hash-url'

    In the above list, 'KEY' is likey a "normalized" url, or perhaps just any url (and the tools would normalize the url behind the scenes to produce the "key").

  2. mid-level tools that make use of the caching tools

    • 'ads-github-user-repos [--owner] [--repo] [--per-page=N] [--page=N]'
    • 'ads-github-org-repos [--org] [--repo]...'
    • 'ads-github-repos [--list-tags] [--list-branches] ...'
    • '...'

  3. high-level tools the build upon the first two levels above

    • 'ads-github-show-rate-limits'
    • 'ads-github-fetch-all-upstreams'
    • 'ads-github-merge-all-upstreams'
    • '...'

That does not seem like a terrible arrangement, but we have learned that there is value in allowing the high-level tools access the low-level cache directly.



ads-github-tools license

GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>

Unless otherwise stated by a different license notice in a particular file, all files in the `ads-github-tools' project are made available under the GNU GPL version 2, or (at your option) any later version.

See the COPYING file for the full license.

Copyright (C) 2016, 2017, 2019, 2020, 2021, 2022 Alan D. Salewski <ads@salewski.email>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Authors and Contributors

The ads-github-tools project code was written by Alan D. Salewski.

The GitHub project page is located at: