drewdeponte / git-ps-rs

Official git-ps Rust implementation - the future of git-ps
https://git-ps.sh
MIT License
78 stars 8 forks source link

Address cleanup of branches when patches have been merged via SCM provider (GitHub) #10

Open drewdeponte opened 2 years ago

drewdeponte commented 2 years ago

Basically the issue is this.

You create your patch. Request review of it (which creates a branch and opens a PR). Then whomever reviewed it or you click the GitHub green button to do a merge, or preferable a rebase & merge to get the change in. This leaves your local branch and potentially the remote branch lying around.

When you do a git ps pull it updates your stack and drops the integrated patch out of the stack. But the local branch and potentially the remote branch are still lying around.

How do we address cleaning those up in this situation?

ctsstc commented 2 years ago

I haven't used it in a long while, but I have a git alias delimb that runs the following:

!git remote prune origin && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs -r git branch -D

I thought it was from this question I've been to, too many times, but it seems I cannot find that there; so I'm not sure where I originally found this. https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged

Running it did the following for a repo (I would be interested to see the output of git branch -vv after git remote prune origin.

─❯ git delimb                                                                                                                                                                                                                                ─╯
Pruning origin
URL: git@github.com:Trayecto/trayecto-client.git
 * [pruned] origin/DB/trayec-237
 * [pruned] origin/dependabot/npm_and_yarn/autoprefixer-10.4.3
 * [pruned] origin/dependabot/npm_and_yarn/autoprefixer-10.4.4
 * [pruned] origin/dependabot/npm_and_yarn/eslint-8.10.0
 * [pruned] origin/dependabot/npm_and_yarn/eslint-8.12.0
 * [pruned] origin/dependabot/npm_and_yarn/eslint-config-next-12.1.1
 * [pruned] origin/dependabot/npm_and_yarn/eslint-config-next-12.1.2
 * [pruned] origin/dependabot/npm_and_yarn/eslint-config-next-12.1.3
 * [pruned] origin/dependabot/npm_and_yarn/eslint-config-next-12.1.4
 * [pruned] origin/dependabot/npm_and_yarn/eslint-plugin-testing-library-5.2.1
 * [pruned] origin/dependabot/npm_and_yarn/heroicons/react-1.0.6
 * [pruned] origin/dependabot/npm_and_yarn/lint-staged-12.3.6
 * [pruned] origin/dependabot/npm_and_yarn/next-12.1.1
 * [pruned] origin/dependabot/npm_and_yarn/next-12.1.2
 * [pruned] origin/dependabot/npm_and_yarn/next-12.1.3
 * [pruned] origin/dependabot/npm_and_yarn/postcss-8.4.11
 * [pruned] origin/dependabot/npm_and_yarn/postcss-8.4.12
 * [pruned] origin/dependabot/npm_and_yarn/postcss-8.4.7
 * [pruned] origin/dependabot/npm_and_yarn/prettier-2.6.0
 * [pruned] origin/dependabot/npm_and_yarn/prettier-2.6.1
 * [pruned] origin/dependabot/npm_and_yarn/prettier-2.6.2
 * [pruned] origin/dependabot/npm_and_yarn/sass-1.49.10
 * [pruned] origin/dependabot/npm_and_yarn/sass-1.49.11
 * [pruned] origin/dependabot/npm_and_yarn/sass-1.49.9
 * [pruned] origin/dependabot/npm_and_yarn/tailwindcss/forms-0.5.0
 * [pruned] origin/dependabot/npm_and_yarn/testing-library/jest-dom-5.16.3
 * [pruned] origin/dependabot/npm_and_yarn/testing-library/user-event-14.0.0
 * [pruned] origin/dependabot/npm_and_yarn/testing-library/user-event-14.0.3
 * [pruned] origin/dependabot/npm_and_yarn/testing-library/user-event-14.0.4
 * [pruned] origin/dependabot/npm_and_yarn/types/jest-27.4.1
 * [pruned] origin/dependabot/npm_and_yarn/types/node-17.0.21
 * [pruned] origin/dependabot/npm_and_yarn/types/node-17.0.23
 * [pruned] origin/dependabot/npm_and_yarn/types/react-17.0.41
 * [pruned] origin/dependabot/npm_and_yarn/types/react-17.0.42
 * [pruned] origin/dependabot/npm_and_yarn/types/react-17.0.43
 * [pruned] origin/dependabot/npm_and_yarn/typescript-4.6.2
 * [pruned] origin/dependabot/npm_and_yarn/typescript-4.6.3
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.13.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.15.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.17.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-5.18.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/parser-5.13.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/parser-5.15.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/parser-5.17.0
 * [pruned] origin/dependabot/npm_and_yarn/typescript-eslint/parser-5.18.0
 * [pruned] origin/ps/rr/change_crudable_plopfile_to_include_methods_and_no_longer_extend_class_
 * [pruned] origin/ps/rr/demo__add_paystub_opens_slider_from_households_page
 * [pruned] origin/ps/rr/extra_line_for_post_merge_script
 * [pruned] origin/ps/rr/fix__some_tsc_errors
 * [pruned] origin/ps/rr/quick_fix__allow_shadow_size_to_be_optional_and_default_to__shadow_
 * [pruned] origin/ps/rr/quick_test_fix_to_match_with_interface_change_on__upsertpaystub_
 * [pruned] origin/ps/rr/refactor___householdtaxsettings___toform______toparams_
 * [pruned] origin/ps/rr/release__v0_0_8_paystub_creation_and_edit_slide_out
 * [pruned] origin/ps/rr/remove_crudable_from_employmenthistorydatasource
 * [pruned] origin/ps/rr/remove_crudable_from_paystub_data_source
 * [pruned] origin/ps/rr/temporary__taxes_overview_static
 * [pruned] origin/ps/rr/trayec_199_create_paystub
 * [pruned] origin/ps/rr/trayec_344_display_list_of_previously_entered_paystubs
 * [pruned] origin/ps/rr/trayec_345_detailed_view_of_paystubs
 * [pruned] origin/ps/rr/trayec_351_edit_paystubs
 * [pruned] origin/ps/rr/trayec_361_vscode_settings_and_extensions_for_workspace
 * [pruned] origin/ps/rr/trayec_364_update_paystub_consumers_via_mutate
 * [pruned] origin/ps/rr/trayec_365_quick_code_coverage_bump
 * [pruned] origin/ps/rr/trayec_366_use_subcategories_in_paystubs
 * [pruned] origin/ps/rr/trayec_370_unique_employer_dropdown_on_paystub_form
 * [pruned] origin/ps/rr/trayec_371_paystub_client_side_validation
 * [pruned] origin/ps/rr/trayec_372_default_paystub_line_item_subcategory_to_the_first
 * [pruned] origin/ps/rr/trayec_373_paystub_upsert_changes
 * [pruned] origin/ps/rr/trayec_379_update_to_use_new_employmenthistory_relationship
 * [pruned] origin/ps/rr/trayec_382_prevent_error_page_within_paystub_table_component
 * [pruned] origin/ps/rr/trayec_383_remove_svg_stroke_1_global_fix
 * [pruned] origin/ps/rr/trayec_385_calculate_net_to_bank_on_paystub_table
 * [pruned] origin/ps/rr/trayec_387_total_all_subcategories_for_paystub_table
 * [pruned] origin/ps/rr/trayec_404_add_initial_paystub_detailed_view
 * [pruned] origin/ps/rr/trayec_422_update_paystub_line_item_data_types
 * [pruned] origin/ps/rr/trayec_423_patch_minimist_vulnerability
 * [pruned] origin/ps/rr/trayec_424_refactor__add_basictab
 * [pruned] origin/ps/rr/trayec_425_add_initial_household_taxes_page
 * [pruned] origin/ps/rr/trayec_426_add_mocked_tax_settings_on_taxes_page
 * [pruned] origin/ps/rr/trayec_436_update_tab_to_new_design
 * [pruned] origin/ps/rr/trayec_438_add_taxsettings_and_filingstatus_models
 * [pruned] origin/ps/rr/trayec_440_add_householdtaxsettingsdatasource_and_gethouseholdtaxsettingsbyid
 * [pruned] origin/ps/rr/trayec_441_add_householdtaxsettings_findall
 * [pruned] origin/ps/rr/trayec_442_and_trayec_443_add_householdtaxsettings_upsert__create_and_update_
 * [pruned] origin/ps/rr/trayec_447_render_tax_settings
 * [pruned] origin/ps/rr/trayec_448_add_simple_loader_icon
 * [pruned] origin/ps/rr/trayec_449_add_error_message
 * [pruned] origin/ps/rr/trayec_451_add_tax_setting_slide_out_and_form
 * [pruned] origin/ps/rr/trayec_453_calculate_household_tax_settings_for_itemized_deductions
 * [pruned] origin/ps/rr/trayec_454_household_tax_settings_calculations___handle_empty_string
 * [pruned] origin/ps/rr/trayec_459_finish_tax_overview_static_layout_
 * [pruned] origin/ps/rr/trayec_472_update_itemized_tax_deductions_to_use_new_data_shape
 * [pruned] origin/ps/rr/update_cardshadow_to_be_more_flexible
 * [pruned] origin/ps/rr/update_employer_data_source_and_use_cases_with_new_endpoints_to_include_company_id
Deleted branch DB/add-crudable-paystubs (was 445c405).
Deleted branch DB/add-crudable-paystubs-backup (was a85f884).
Deleted branch DB/add-employers-form (was 2847725).
Deleted branch DB/add-generators (was 965139c).
Deleted branch DB/add-get-household-equity-grants (was ccb6282).
Deleted branch DB/add-wm (was cefa004).
Deleted branch DB/initial-structure (was f1323da).
Deleted branch DB/shorten-names (was 4c57444).
Deleted branch DB/simplify-crud (was e717266).
Deleted branch DB/trayec-313 (was 67d99ac).
Deleted branch DB/trayec-328 (was 349e93e).
Deleted branch dependabot/npm_and_yarn/testing-library/user-event-14.0.4 (was e75a8e4).
Deleted branch ps/rr/trayec_181_polish_up_company_list_to_match_design (was 4a16936).
Deleted branch ps/rr/trayec_442_and_trayec_443_add_householdtaxsettings_upsert__create_and_update_ (was a906fab).
drewdeponte commented 2 years ago

So far the thoughts around this is that we might have something like the following.

drewdeponte commented 2 years ago

@RyanHedges in issue #9 said the following to which I replied.

git-ps delete

Given this is the most "destructive" of the delete commands I wonder if we should make the name more special? Three commands start with delete. It may make for possible mistakes with autocomplete. Maybe git-ps remove, git-ps destroy? Maybe the others branch related ones have a different name branch-delete-remote and branch-delete? Especially since this runs as non interactive.

While a prompt might be more suited for nuke, maybe an "are you sure? (Y/N)" prompt that can be skipped? Maybe we could call it drop so it is in alignment with the drop action in the interactive rebase. The branch related ones could stay delete which is in alignment with the git naming of commands. I agree that definitely could do things like prompt with the nuke command.

drewdeponte commented 2 years ago

As I was implementing the branch override (-n ) option for the branch, sync, request-review, and integrate commands. I realized that another usecase for something along these lines would be to remove not only the branches but also the branch association stored on disk. This would allow users to then specify a branch via -n if they had already previously accidentally let it generate a branch name.