repobee / repobee-sanitizer

A plugin for sanitizing master repositories before distribution to students
MIT License
2 stars 3 forks source link

Enable pull request workflow #121

Closed slarse closed 3 years ago

slarse commented 3 years ago

It would be a nice feature to be able to enable a pull request workflow, such that we can lock the master/main branch of the template repositories. I'm thinking that sooner or later, someone will push to the master branch in a template repository unless we lock it down.

The neatest thing would be if there was simply a --pull-request argument on the sanitize repo command, which instead of pushing to the target branch opens a PR to it. This will require some expansion of the API, but we can implement a prototype here first, and then figure out what we need the API to do.

@tohanss thoughts?

tohanss commented 3 years ago

I agree, although if someone pushes to master we will still have the solutions branch meaning that nothing is broken (though more work will have to be done)

tohanss commented 3 years ago

By more work is mean reverting the changes and telling the person who pushed to master what should be done instead

slarse commented 3 years ago

Yeah but that's only if someone who knows to use the solutions branch discovers it.

tohanss commented 3 years ago

True. Also, if someone pushes directly to master, will adding a --pull-request argument really stop them from doing that anyway unless we make it default?

slarse commented 3 years ago

True. Also, if someone pushes directly to master, will adding a --pull-request argument really stop them from doing that anyway unless we make it default?

We simply lock the master branch in the template repos. Anyone can mess up locally, but no one can push, so you can't not discover that you messed up.

A pretty simple workaround here (instead of a somewhat complicated --pull-request argument) would be to add an option --create-pr-branch, or something like that. So, if you call sanitizer like so:

$ repobee -p sanitizer sanitize repo --target-branch master --create-pr-branch some-branch-name

Then sanitizer will create a new branch some-branch-name from master, and commit there instead. Then the user can easily create a PR manually. It's slightly confusing from a terminology perspective (i.e. --target-branch isn't actually where the commit ends up), but I think it would be pretty simple to implement, and also pretty simple to test.