nicoespeon / gitgraph.js

[ARCHIVED] A JavaScript library to draw pretty git graphs in the browser
https://www.nicoespeon.com/gitgraph.js
MIT License
3.02k stars 363 forks source link

Branch Deletion #399

Closed acransac closed 3 years ago

acransac commented 3 years ago

This patch adds the possibility to delete a branch. It extends the branch user API so one can call someBranch.delete() and see the branch disappear from the rendered graph if it is not merged before.

Concretely, it clears out the branch name from the graph's branches property and from its refs. Commits and tags from the branch remain in the graph. Once a branch is deleted, the branch user API throws for the operations that don't make sense anymore. It is also impossible to delete a branch when it is checked out.

On the rendering side, only commits that are not reachable somehow disappear from view. This means that if the deleted branch was merged beforehand, the commits stay visible.

To the best of my understanding of the code, this change is compatible with previous use and behavior (notably, all tests pass without update). I also added tests and stories to cover what I added.

Closes #388

nicoespeon commented 3 years ago

@all-contributors please add acransac for code, bug

allcontributors[bot] commented 3 years ago

@nicoespeon

I've put up a pull request to add @acransac! :tada: