Skip to content

offline usage: parse GitHub username from ~/.netrc (new tool: parse-netrc) #60

@salewski

Description

@salewski

This is a "retro bug" related to issue #59. While addressing that issue, it was realized that we needed a way to determine the username of the "in-effect GitHub user" without accessing the network, in the same way that curl(1) determines it when using its -n (--netrc) option. This is needed because some GitHub users have multiple GitHub accounts (e.g., work and personal), but access both from a single Unix account. We need to be able to tell them apart so we can keep separate per-GitHub-user caches.

We recently introduced the ads-github-whoami(1) utility (see issue #52) to obtain the info about the authenticated GitHub user, but that tool requires network access at runtime. Our cache needs to be able to work entirely offline for some use cases. The first approach considered was to just use curl to get the info, either from the curl command line utility, or from a custom program written against libcurl. It turns out that the functions related to parsing the user's ~/.netrc file are not intended as public symbols in libcurl, so we kept looking.

Eventually it was decided that a custom tool would be introduced for the purpose. Enter the new parse-netrc utility.

The program currently lives in-tree in the ads-github-tools project, but (as suggested by the lack of an "ads-github-" prefix in its name) it is a candidate for extracting from the tree. Time will tell.

In any event, this retro bug now gives me a place to point as I update the NEWS file.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions