git-branch--stray 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/README.md +32 -28
- data/exe/git-branch--delete--stray +1 -1
- data/exe/git-branch--list--stray +1 -1
- data/git-branch--stray.gemspec +2 -2
- data/lib/git/branch/stray/version.rb +1 -1
- data/lib/git/branch/stray.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd358f7d6dcc8b853965067aef2baf5686af5906
|
4
|
+
data.tar.gz: 19775be68826ebd2003cb0f00194bf54865c8fb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d201ec5055943cc18b5a6a798b6b9a756dce3be9ef5f0d48d55216d937ac6105f4274433de86c075b5e11295a594e127d756de3af84942fdedca07a14875e84f
|
7
|
+
data.tar.gz: 3bf9f3e8c9b493ab920b9d5e18c5bab35d45f771b1022056768c420d324853383c470ce4287bd8eba8801978061a89a5d86a13cf1c39a62c9734e97a48fbde53
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.7
|
data/README.md
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
#
|
1
|
+
# List and delete "stray" git branches
|
2
2
|
|
3
|
-
##
|
3
|
+
## Summary
|
4
4
|
|
5
|
-
Run `git branch--delete--stray` to delete local
|
5
|
+
Run `git branch--delete--stray` to delete local tracking branches for which the remote branch being tracked has been deleted on the remote... use `git branch--list--stray` to just list them; both work best with [regular pruning](#pruning) of remote-tracking references!
|
6
6
|
|
7
7
|
## Background
|
8
8
|
|
9
|
-
Git has a default disposition of keeping data unless it's explicitly thrown away; this extends to _(unnecessarily)_ holding onto references to so-called local "remote-tracking" branches where the branch being tracked has long since been deleted on the remote itself.
|
9
|
+
Git has a default disposition of keeping data unless it's explicitly thrown away; this extends to _(unnecessarily?)_ holding onto references to so-called local "remote-tracking" branches where the branch being tracked has long since been deleted on the remote itself.
|
10
10
|
|
11
|
-
This utility refers to these local branches as "stray" branches, and includes two git extensions: one for listing all "stray" branches, and a second one for _(selectively)_ deleting them.
|
11
|
+
This utility refers to these local tracking branches as "stray" branches, and includes two git extensions: one for listing all "stray" branches, and a second one for _(selectively)_ deleting them.
|
12
12
|
|
13
|
-
In case of the [GitHub Flow](https://guides.github.com/introduction/flow/) for instance, a local branch would become "stray" after a pull request gets merged and the underlying remote branch gets deleted... after the next `git fetch` it would be possible to identify the "stray" branch with something akin to `git branch --list --merged
|
13
|
+
In case of the [GitHub Flow](https://guides.github.com/introduction/flow/) for instance, a local branch would become "stray" after a pull request gets merged and the underlying remote branch gets deleted... after the next `git fetch` it would be possible to identify the "stray" branch with something akin to `git branch --list --merged`, and delete them accordingly.
|
14
14
|
|
15
|
-
But that's not the only scenario that results in "stray" branches, which is why the various "solutions" you find on Stack Overflow don't typically cover all edge cases, whereas this utility does;
|
15
|
+
But that's not the only scenario that results in "stray" branches, which is why the various "solutions" you find on Stack Overflow don't typically cover all edge cases, whereas this utility does; it also prefers git plumbing over git porcelain, and it implements most of its logic in a library, making it very straightforward to implement even more git extensions for dealing with "stray" branches.
|
16
16
|
|
17
17
|
## What's in a name?
|
18
18
|
|
19
|
-
In the context of this utility, a branch is considered "stray" if it is what git calls a "remote-tracking" branch but one where the remote branch it was tracking no longer exists _(ie. where the branch it was tracking has been deleted on the remote, e.g. on GitHub or on Bitbucket)_.
|
19
|
+
In the context of this utility, a branch is considered "stray" if it is what git calls [a "remote-tracking" branch](https://git-scm.com/book/id/v2/Git-Branching-Remote-Branches#_tracking_branches), but one where the remote branch it was tracking no longer exists _(ie. where the branch it was tracking has been deleted on the remote, e.g. on GitHub or on Bitbucket)_.
|
20
20
|
|
21
21
|
The term "stray" was chosen to avoid confusion with existing git terminology like ''merged", "tracked" and even "orpaned".
|
22
22
|
|
23
23
|
Also, the names of the two git extensions implemented by this utility:
|
24
24
|
|
25
|
-
* `git
|
26
|
-
* `git
|
25
|
+
* `git branch--list--stray`
|
26
|
+
* `git branch--delete--stray`
|
27
27
|
|
28
|
-
... were chosen two mimic some existing `git branch`
|
28
|
+
... were chosen two mimic some existing `git branch` options:
|
29
29
|
|
30
30
|
* `git branch --list --merged`
|
31
31
|
* `git branch --delete`
|
@@ -34,29 +34,17 @@ respectively.
|
|
34
34
|
|
35
35
|
## Installation
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
gem 'git-branch--stray'
|
41
|
-
```
|
42
|
-
|
43
|
-
And then execute:
|
44
|
-
|
45
|
-
$ bundle
|
46
|
-
|
47
|
-
Or install it yourself as:
|
48
|
-
|
49
|
-
$ gem install git-branch--stray
|
37
|
+
gem install git-branch--stray
|
50
38
|
|
51
39
|
## Usage
|
52
40
|
|
53
|
-
After installing the gem, you will have two new git extensions in your environment: `git-branch--list--stray` will list all stray branches, whereas `git-branch--delete--stray` will iterate over the list and - after prompting for confirmation - delete any stray branches
|
41
|
+
After installing the gem, you will have two new git extensions in your environment: `git-branch--list--stray` will list all stray branches, whereas `git-branch--delete--stray` will iterate over the list and - after prompting for confirmation - delete any stray branches.
|
54
42
|
|
55
|
-
Because they will be in your local `$PATH` you can run them as so-called git subcommands as follows:
|
43
|
+
Because they will be in your local `$PATH` you can run them as so-called git subcommands, as follows:
|
56
44
|
|
57
45
|
```
|
58
46
|
git branch--list--stray
|
59
|
-
git branch--delete
|
47
|
+
git branch--delete--stray
|
60
48
|
```
|
61
49
|
|
62
50
|
Most likely, though, you will want to create some [git aliases](https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases) to make it easier to work with the two utility scripts:
|
@@ -70,7 +58,23 @@ Alternatively, a similar approach can be used to add either of the scripts to yo
|
|
70
58
|
|
71
59
|
## Pruning
|
72
60
|
|
73
|
-
The two git extensions work best if your git workflow includes regular pruning of remote-tracking references that no longer exist on the remote, either by running `git fetch --prune` when syncing with the remote in question, or else configuring [git's pruning behaviour](https://git-scm.com/docs/git-fetch#_pruning) for your environment.
|
61
|
+
The two git extensions work best if your git workflow includes regular pruning of remote-tracking references that no longer exist on the remote, either by running [`git fetch --prune`](https://git-scm.com/docs/git-fetch#git-fetch--p) when syncing with the remote in question, or else configuring [git's pruning behaviour](https://git-scm.com/docs/git-fetch#_pruning) for your environment.
|
62
|
+
|
63
|
+
## Extending
|
64
|
+
|
65
|
+
Most of the utility is implemented in a Ruby library, making it very easy to use the logic for dealing with "stray" branches in your own Ruby applications or utilities.
|
66
|
+
|
67
|
+
Add this line to your application's Gemfile:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
gem 'git-branch--stray'
|
71
|
+
```
|
72
|
+
|
73
|
+
And then execute:
|
74
|
+
|
75
|
+
$ bundle
|
76
|
+
|
77
|
+
The library to require is in the [`lib/git/branch/stray.rb`](lib/git/branch/stray.rb) file.
|
74
78
|
|
75
79
|
## Development
|
76
80
|
|
data/exe/git-branch--list--stray
CHANGED
data/git-branch--stray.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'git/branch/stray/version'
|
4
4
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'Delete local tracking branches that have been strayed'
|
13
13
|
spec.homepage = 'https://github.com/pvdb/git-branch--stray'
|
14
14
|
|
15
|
-
spec.files = Dir.chdir(File.expand_path(
|
15
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
16
|
`git ls-files -z`
|
17
17
|
.split("\x0")
|
18
18
|
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/git/branch/stray.rb
CHANGED
@@ -71,6 +71,7 @@ module Git
|
|
71
71
|
stray_branches.each_consented('Delete stray branch "%s"') do |stray|
|
72
72
|
system("git branch -d #{stray}")
|
73
73
|
next if $CHILD_STATUS.success?
|
74
|
+
|
74
75
|
Array(stray).each_consented('Delete unmerged branch "%s"') do |unmerged|
|
75
76
|
system("git branch -D #{unmerged}")
|
76
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-branch--stray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Vandenberk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: consenter
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.5.2.3
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Delete local tracking branches that have been strayed
|