Skip to content

Latest commit

 

History

History
115 lines (79 loc) · 3.63 KB

README.md

File metadata and controls

115 lines (79 loc) · 3.63 KB

gfp (GitHub follower path)

Find a path of followers between two GitHub users.

Contents

Demo

Coming soon.

Installation

You should have Go installed and configured.

Install with go get:

$ go get -u -v github.com/kshvmdn/gfp/...
$ which gfp
$GOPATH/bin/gfp

Or, install directly via source:

$ git clone https://github.com/kshvmdn/gfp.git $GOPATH/src/github.com/kshvmdn/gfp
$ cd $_
$ make install && make
$ ./gfp

Setup

gfp uses the GitHub API, so you'll be required to register an application.

Head over to this page and generate a new token. Give it a name (anything works) and hit Generate token (no scope required).

Copy the token and export it as an environment variable.

$ export GITHUB_ACCESS_TOKEN=<access token>

Usage

gfp takes two GitHub usernames: an origin and a target.

The program starts at the origin user and recursively builds a directed graph based on who this user is following. This process is repeated until the target is reached (or the API rate limit is exceeded).

You can generally expect a different path each run (particularly for popular accounts), this is because the traversal order is unpredicatable (we're running everything concurrently, so it's not possible to control order).

gfp is built on top of a concurrent job queue with 6 workers by default. You can change this number with the -workers flag.

Log output is redirected to /dev/null, use the -show-log flag to disable this.

View the usage dialogue with the -help flag.

$ gfp -help
usage: gfp [options] origin target
  -show-log
        show log output
  -version
        print version and exit
  -workers int
        number of workers (default 6)

Examples

$ gfp kshvmdn torvalds
kshvmdn -> ... -> torvalds
$ gfp -show-log kshvmdn torvalds
2017/05/28 05:53:09 worker 1: kshvmdn
2017/05/28 05:53:10 worker 4: ...
2017/05/28 05:53:10 worker 5: ...
2017/05/28 05:53:10 worker 2: ...
2017/05/28 05:53:10 worker 6: ...
...
kshvmdn -> ... -> torvalds

Contribute

gfp is completely open source. Feel free to open an issue or a pull request.

Prior to submitting work, please ensure your changes comply with Golint, test this with make lint.

Todo

  • Find shortest path, might be impossible to find the shortest path (due to rate limits), but it is possible to do something like: run until we find x paths and return the shortest of those x.
  • I think we can do some cool stuff with the resultant graph. Perhaps add a flag to export it once the computation is complete (maybe do something with awalterschulze/gographviz?).
  • Better-handle rate limit (perhaps it's possible to pause execution and wait until more requests are available?).
  • Handle the case where we run out of users to traverse and haven't found the target (also, similar: origin user is following 0 people).

Credits

License

gfp source code is released under the MIT license.