mcasper / git-clean

A Command Line Tool written in Rust for cleaning up local and remote Git branches
MIT License
53 stars 8 forks source link

Integration tests and bug fix #15

Closed mcasper closed 8 years ago

mcasper commented 8 years ago

Our current unit tests don't really give any assurance that git-clean actually works, just that a few of the outputs remain the same. The only way to really test that I haven't broken everything is through integration tests, where we set up a git repo, commit some branches, and try deleting them. This adds the integration tests framework, and some of the core tests around deleting functionality, all using local branches at the moment.

A git remote can be a local folder, so that'll be the next target for tests.

Recently I swapped us over to using git branch --contains master, which was pretty silly of me - most branches contain master's current commit, depending on the size of project you're working on. This could lead to a situation where git-clean would delete branches that are entirely valid and ahead of master, not quite the desired behavior.

Turns out that all we needed to do was drop the branch argument from git branch --merged, it's already smart enough on its own to handle squashed merges (as proven now by our integration tests!).

mcasper commented 8 years ago

@jfrost @mikeastock You two are the primary users that I know about, if you're on 0.2.2 you should bump up to 0.3.0 (which I'll release when I merge this), as I don't want git-clean to delete any legitimate branches without you guys noticing