git-switcher 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -19
- data/.pryrc +8 -0
- data/.rubocop.yml +41 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -4
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +0 -7
- data/Gemfile.lock +49 -0
- data/LICENSE.txt +17 -18
- data/README.md +7 -5
- data/Rakefile +21 -20
- data/bin/console +9 -0
- data/bin/setup +15 -0
- data/exe/git-switcher +55 -0
- data/git-switcher.gemspec +30 -48
- data/lib/ext/rugged.rb +15 -0
- data/lib/git/switcher/menu.rb +102 -0
- data/lib/git/switcher/version.rb +10 -0
- data/lib/git/switcher.rb +15 -0
- metadata +47 -277
- data/Guardfile +0 -17
- data/bin/git-switcher +0 -63
- data/features/help_and_version.feature +0 -20
- data/features/step_definitions/git-switcher_steps.rb +0 -21
- data/features/support/env.rb +0 -7
- data/lib/git-switcher/banner.rb +0 -13
- data/lib/git-switcher/copyright.rb +0 -6
- data/lib/git-switcher/menu.rb +0 -99
- data/lib/git-switcher/repo.rb +0 -93
- data/lib/git-switcher/version.rb +0 -5
- data/lib/git-switcher.rb +0 -17
- data/spec/lib/git-switcher/repo_spec.rb +0 -9
- data/spec/lib/git-switcher_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -8
data/lib/git-switcher/repo.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'rugged'
|
2
|
-
|
3
|
-
class Git::Switcher::Repo < Rugged::Repository
|
4
|
-
|
5
|
-
def repo
|
6
|
-
# a bug/feature in Rugged prevents us from using instances of a subclass of Rugged::Repository
|
7
|
-
# in certain methods/places; instead it insists on an instance of Rugged::Repository itself...
|
8
|
-
# (meaning we can't use `self` on those occasions!) where is Barbara Liskov when you need her?
|
9
|
-
@repo ||= Rugged::Repository.new(self.path)
|
10
|
-
end
|
11
|
-
|
12
|
-
def current_branch
|
13
|
-
Rugged::Reference.lookup(self, 'HEAD').target.scan(/\Arefs\/heads\/(.*)\Z/).flatten.first
|
14
|
-
end
|
15
|
-
|
16
|
-
def current_head? ref
|
17
|
-
target('HEAD') == target(ref)
|
18
|
-
end
|
19
|
-
|
20
|
-
def reachable? ref
|
21
|
-
self.class.reachable? target('HEAD'), target(ref)
|
22
|
-
end
|
23
|
-
|
24
|
-
def abbreviated_name ref
|
25
|
-
ref.gsub(/\Arefs\/(remotes|heads|tags)\//, '')
|
26
|
-
end
|
27
|
-
|
28
|
-
# remote branches
|
29
|
-
|
30
|
-
def remote_branches
|
31
|
-
self.refs.find_all { |ref| ref =~ /\Arefs\/remotes\// && ref !~ /\/HEAD\Z/ }
|
32
|
-
end
|
33
|
-
|
34
|
-
def remote_branch_name ref
|
35
|
-
ref.gsub(/\Arefs\/remotes\//, '')
|
36
|
-
end
|
37
|
-
|
38
|
-
def remote_branch_names
|
39
|
-
remote_branches.map { |ref| remote_branch_name(ref) }
|
40
|
-
end
|
41
|
-
|
42
|
-
# local branches
|
43
|
-
|
44
|
-
def local_branches
|
45
|
-
self.refs.find_all { |ref| ref =~ /\Arefs\/heads\// }
|
46
|
-
end
|
47
|
-
|
48
|
-
def local_branch_name ref
|
49
|
-
ref.gsub(/\Arefs\/heads\//, '')
|
50
|
-
end
|
51
|
-
|
52
|
-
def local_branch_names
|
53
|
-
local_branches.map { |ref| local_branch_name(ref) }
|
54
|
-
end
|
55
|
-
|
56
|
-
# tags
|
57
|
-
|
58
|
-
def tags
|
59
|
-
self.refs.find_all { |ref| ref =~ /\Arefs\/tags\// }
|
60
|
-
end
|
61
|
-
|
62
|
-
def reachable_tags # time-ordered, as well
|
63
|
-
tags.find_all { |tag| reachable? tag }.sort { |first_tag, second_tag|
|
64
|
-
# use 'author' timestamp, not 'committer' timestamp, e.g. in case
|
65
|
-
# the tag's target commit was the result of a rebase operation!!!
|
66
|
-
target(first_tag).author[:time] <=> target(second_tag).author[:time]
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def tag_name ref
|
71
|
-
ref.gsub(/\Arefs\/tags\//, '')
|
72
|
-
end
|
73
|
-
|
74
|
-
def tag_names
|
75
|
-
tags.map { |ref| tag_name(ref) }
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def target ref
|
81
|
-
# TODO read up on git tagging, ie. tag another tag, ad infinitum (?)
|
82
|
-
target = self.repo.lookup(Rugged::Reference.lookup(self, ref).resolve.target)
|
83
|
-
target = target.target if target.is_a? Rugged::Tag
|
84
|
-
target
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.reachable? current_commit, past_commit
|
88
|
-
(current_commit == past_commit) || begin
|
89
|
-
current_commit.parents.any? { |parent| self.reachable? parent, past_commit }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
data/lib/git-switcher/version.rb
DELETED
data/lib/git-switcher.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
require 'rugged'
|
4
|
-
require 'trollop'
|
5
|
-
|
6
|
-
require 'git-switcher/version'
|
7
|
-
require 'git-switcher/banner'
|
8
|
-
require 'git-switcher/copyright'
|
9
|
-
|
10
|
-
require 'git-switcher/repo'
|
11
|
-
require 'git-switcher/menu'
|
12
|
-
|
13
|
-
module Git
|
14
|
-
module Switcher
|
15
|
-
# Your code goes here...
|
16
|
-
end
|
17
|
-
end
|