-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebasing lots of branches can also result in lots of loose objects. This command will run `git gc` as well as cleaning up branches that are no longer needed. Branches that have been merged into the root branch and remote branches that are no longer present.
- Loading branch information
Showing
8 changed files
with
146 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# class that will prune remote branches, garbage collect, and delete merged | ||
# branches | ||
module Baes::Actions::Clean | ||
class << self | ||
include Baes::Configuration::Helpers | ||
|
||
# run the command | ||
def call | ||
output.puts("cleaning up branches") | ||
git.checkout(root_name) | ||
git.remote_prune("origin") | ||
git.gc | ||
git.delete_branches(merged_branches) | ||
end | ||
|
||
private | ||
|
||
def merged_branches | ||
branches = git.branch_names("--merged") | ||
branches.select do |branch| | ||
branch != root_name && !ignored_branch_names.include?(branch) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Baes::Actions::Clean do | ||
describe "#call" do | ||
it "calls git gc" do | ||
FakeGit.branch_names = ["main", "my_branch"] | ||
|
||
described_class.call | ||
|
||
expect(FakeGit.gc_called).to be(true) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters