chihacknight / civic-json-worker

Worker script that pulls metadata about opengov projects
MIT License
24 stars 65 forks source link

Handle projects at GitHub whose main branch is not 'master'. #19

Closed kfogel closed 10 years ago

kfogel commented 10 years ago

It would be useful to be able to specify branch(es) to pay attention towhen adding a new project, since not all projects use master as their main development branch.

For example, NYCComptroller/Checkbook does their main development on the checkbook_nyc branch right now. But in http://opengovhacknight.org/projects.html, the project looks like it has very low commit activity, because only master is examined.

The commit here is an untested draft -- I don't expect that it works out-of-the-box, and didn't have a GITHUB_TOKEN set up to test with (sorry). But sometimes a patch is the best way to express an idea, so here it is! I hope it's a useful start.

evz commented 10 years ago

Looks like there is a way to wrangle this but not exactly in the way you're proposing (see: http://developer.github.com/v3/repos/#get-branch). Maybe we can talk about this tomorrow night? Should be pretty simple to implement.

kfogel commented 10 years ago

Eric van Zanten notifications@github.com writes:

Looks like there is a way to wrangle this but not exactly in the way you're proposing (see: http://developer.github.com/v3/repos/#get-branch). Maybe we can talk about this tomorrow night? Should be pretty simple to implement.

I'll be there tomorrow night -- would love to get this done with you!

-K

kfogel commented 10 years ago

Okay, @evz and I took a look at what this would take. Our opinion: it's not worth it -- instead, just encourage upstream projects to set their "default branch" on GitHub to whatever their true default branch is.

But, if you do want to add non-master branch support in civic-json-worker, our thought was: change the format of the input file (projects.json) so that it's a list of strings or dicts. Strings are the default right now -- that's the common case, where you just specify a GitHub project URL and civic-json-worker Does The Right Thing, seeking the master branch. But if it's a dict, then it's something like this:

{ "project_url": "https://github.com/NYCComptroller/Checkbook",
"active_branches": ["branch_name_1", "branch_name_2", ...]}

Then in tasks.py:update_project, take optional parameter active_branches=[]. If present, Do The Needful (warning: this implies some rewrite of the function's body, because some parts of it will need to iterate over the branches while other parts won't). Update its callers. Come up with some reasonable UI on the project submission front end. Profit.