Skip to content

Adds feature to auto-prune local branches - #6544

Merged
shiftkey merged 112 commits into
developmentfrom
cleanup-branches
Feb 6, 2019
Merged

shiftkey merged 112 commits into
developmentfrom
cleanup-branches

Conversation

@iAmWillShepherd

@iAmWillShepherd iAmWillShepherd commented Jan 7, 2019 •

Copy link
Copy Markdown
Contributor

Fixes #750

This PR adds a feature that will auto-prune branches based on these conditions:

  • The branch is deleted on GitHub.com and
  • merged locally into the default branch in Desktop and
  • has no commits ahead of the default branch

It will run once a repo is opened and every 24 hours for that repo, but only when that repo is opened. This means if a repo is not opened in 3 days, the next time it will be pruned is when that repo is opened. If a repo was just pruned, the next check will be 24 hours later if that repo is opened. To accomplish this, I'll likely use IndexedDB to store last time a repo was pruned.

Note that this PR does not include logic to only delete branches that haven't been checked out within 14 days. That logic is captured in #6664 and will be integrated after it is merged.

Todo:

  • Get list of merged branches
  • Filter out currently checked-out branch
  • Filter out local branches that still exist on remote
  • Filter out local branches that are ahead of default branch (Running git branch --merged takes care of this)
  • Run prune function on an interval that starts when repo is opened
  • Update model schema to include last prune date in the repository table
  • Remove test code used for dev purposes
  • Test - make sure reserved branches don't get deleted
  • Add logic to only add branch to prune list if last checkout was more than 14 days ago - Add git function to get branch checkouts from reflog #6664

@shiftkey shiftkey added this to the 1.6.0 milestone Jan 7, 2019
@billygriffin

Copy link
Copy Markdown
Contributor

@iAmWillShepherd I'm excited to see this! Prior to adding ready-to-review here, would you mind clarifying scope and where you netted out from the conversation in #750? Just want to make sure we're all aligned on where we're starting with this. Thanks!

@iAmWillShepherd

Copy link
Copy Markdown
Contributor Author

@billygriffin This is still very much WIP. I added a high-level overview of what I have left.

sensetv
sensetv previously approved these changes Jan 7, 2019

@sensetv sensetv left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to unrelated file removed by moderator

sensetv
sensetv previously approved these changes Jan 8, 2019
Comment thread app/test/unit/branch-pruner-test.ts Resolved
Comment thread app/test/unit/branch-pruner-test.ts Resolved
Comment thread app/test/unit/branch-pruner-test.ts Resolved
Comment thread app/test/unit/branch-pruner-test.ts Resolved
Comment thread app/test/unit/branch-pruner-test.ts Resolved
@shiftkey shiftkey self-assigned this Feb 6, 2019
@iAmWillShepherd

Copy link
Copy Markdown
Contributor Author

💯

@shiftkey

shiftkey commented Feb 6, 2019

Copy link
Copy Markdown
Member

This has gone through a long review process and is feature-flagged for development currently, so to prevent further delays I plan to merge this in around 1pm SF time today so we can unblock #6664.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants