gitXplorer 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 46c6a23891882880010d51ef9ff4b9d7d76df67694b8cd744f47cad8cd5b9ee3
4
+ data.tar.gz: ee9d7cd15d04aa37bda96ed0eaaa6ef6c00a121428ecb9a2f2e532c2edc7dc1e
5
+ SHA512:
6
+ metadata.gz: 8e8dcf978ea02cd1b572e76639c92c71e468af9f42621388d033f45bd76810ea6a1ff95040570ed666b404ebd2a6d13df8d53b629b50627535f8fc9d0509bd9c
7
+ data.tar.gz: 478ecbb30a9ef3eb6cea1559b7b85eb0562be5b598083e695d51c0802bca7364570347850d5ad0f8ea952e760ee3c0641a8b670f1bea90d57b4090457430b3fe
data/bin/gitX ADDED
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "djinni"
4
+ require "git_xplorer"
5
+ require "hilighter"
6
+ require "io/wait"
7
+ require "optparse"
8
+
9
+ class GitXplorerExit
10
+ GOOD = 0
11
+ INVALID_OPTION = 1
12
+ INVALID_ARGUMENT = 2
13
+ MISSING_ARGUMENT = 3
14
+ EXTRA_ARGUMENTS = 4
15
+ EXCEPTION = 5
16
+ AMBIGUOUS_ARGUMENT = 6
17
+ end
18
+
19
+ def parse(args)
20
+ options = Hash.new
21
+ options["verbose"] = false
22
+
23
+ info = [
24
+ "Drop into a shell-like environment that simulates a",
25
+ "filesystem. Easily navigate thru directories and browse all",
26
+ "files across all revisions."
27
+ ].join(" ")
28
+
29
+ parser = OptionParser.new do |opts|
30
+ opts.summary_width = 19
31
+
32
+ opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
33
+
34
+ opts.on("")
35
+
36
+ info.scan(/\S.{0,80}\S(?=\s|$)|\S+/).each do |line|
37
+ opts.on("#{line}")
38
+ end
39
+
40
+ opts.on("", "OPTIONS")
41
+
42
+ opts.on("-h", "--help", "Display this help message") do
43
+ puts opts
44
+ exit GitXplorerExit::GOOD
45
+ end
46
+
47
+ opts.on("--nocolor", "Disable colorized output") do
48
+ Hilighter.disable
49
+ end
50
+
51
+ opts.on(
52
+ "-v",
53
+ "--verbose",
54
+ "Show backtrace when error occurs"
55
+ ) do
56
+ options["verbose"] = true
57
+ end
58
+ end
59
+
60
+ begin
61
+ parser.parse!(args)
62
+ rescue OptionParser::InvalidOption => e
63
+ puts e.message
64
+ puts parser
65
+ exit GitXplorerExit::INVALID_OPTION
66
+ rescue OptionParser::InvalidArgument => e
67
+ puts e.message
68
+ puts parser
69
+ exit GitXplorerExit::INVALID_ARGUMENT
70
+ rescue OptionParser::MissingArgument => e
71
+ puts e.message
72
+ puts parser
73
+ exit GitXplorerExit::MISSING_ARGUMENT
74
+ rescue OptionParser::AmbiguousOption => e
75
+ puts e.message
76
+ puts parser
77
+ exit GitXplorerExit::AMBIGUOUS_ARGUMENT
78
+ end
79
+
80
+ if (!args.empty?)
81
+ puts parser
82
+ exit GitXplorerExit::EXTRA_ARGUMENTS
83
+ end
84
+
85
+ return options
86
+ end
87
+
88
+ begin
89
+ options = parse(ARGV)
90
+ rescue Interrupt
91
+ # Exit gracefully on ^C
92
+ exit GitXplorerExit::GOOD
93
+ end
94
+
95
+ begin
96
+ gitx = GitXplorer.new
97
+
98
+ djinni = Djinni.new
99
+ djinni.fallback = "git"
100
+ djinni.load_wishes(
101
+ "#{File.dirname(__FILE__)}/../lib/git_xplorer/wish"
102
+ )
103
+ djinni.prompt({"gitXplorer" => gitx}, "#{gitx.pwd}$ ".light_white)
104
+ rescue SystemExit
105
+ # Quite from djinni
106
+ # Exit gracefully
107
+ rescue Interrupt
108
+ # Exit gracefully on ^C
109
+ rescue Errno::EPIPE
110
+ # Do nothing. This can happen if piping to another program such as
111
+ # less. Usually if less is closed before we're done with STDOUT.
112
+ rescue GitXplorer::Error => e
113
+ puts e.message
114
+ exit GitXplorerExit::EXCEPTION
115
+ rescue Exception => e
116
+ $stderr.puts [
117
+ "Oops! Looks like an error has occured! If the error",
118
+ "persists, file a bug at:"
119
+ ].join(" ").wrap
120
+ $stderr.puts
121
+ $stderr.puts " https://gitlab.com/mjwhitta/git_xplorer/issues"
122
+ $stderr.puts
123
+ $stderr.puts [
124
+ "Maybe the message below will help. If not, you can use the",
125
+ "--verbose flag to get a backtrace."
126
+ ].join(" ").wrap
127
+ $stderr.puts
128
+
129
+ $stderr.puts e.message.white.on_red
130
+ if (options["verbose"])
131
+ e.backtrace.each do |line|
132
+ $stderr.puts line.light_yellow
133
+ end
134
+ end
135
+ exit GitXplorerExit::EXCEPTION
136
+ end
137
+ exit GitXplorerExit::GOOD
data/bin/gitXplorer ADDED
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "djinni"
4
+ require "git_xplorer"
5
+ require "hilighter"
6
+ require "io/wait"
7
+ require "optparse"
8
+
9
+ class GitXplorerExit
10
+ GOOD = 0
11
+ INVALID_OPTION = 1
12
+ INVALID_ARGUMENT = 2
13
+ MISSING_ARGUMENT = 3
14
+ EXTRA_ARGUMENTS = 4
15
+ EXCEPTION = 5
16
+ AMBIGUOUS_ARGUMENT = 6
17
+ end
18
+
19
+ def parse(args)
20
+ options = Hash.new
21
+ options["verbose"] = false
22
+
23
+ info = [
24
+ "Drop into a shell-like environment that simulates a",
25
+ "filesystem. Easily navigate thru directories and browse all",
26
+ "files across all revisions."
27
+ ].join(" ")
28
+
29
+ parser = OptionParser.new do |opts|
30
+ opts.summary_width = 19
31
+
32
+ opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
33
+
34
+ opts.on("")
35
+
36
+ info.scan(/\S.{0,80}\S(?=\s|$)|\S+/).each do |line|
37
+ opts.on("#{line}")
38
+ end
39
+
40
+ opts.on("", "OPTIONS")
41
+
42
+ opts.on("-h", "--help", "Display this help message") do
43
+ puts opts
44
+ exit GitXplorerExit::GOOD
45
+ end
46
+
47
+ opts.on("--nocolor", "Disable colorized output") do
48
+ Hilighter.disable
49
+ end
50
+
51
+ opts.on(
52
+ "-v",
53
+ "--verbose",
54
+ "Show backtrace when error occurs"
55
+ ) do
56
+ options["verbose"] = true
57
+ end
58
+ end
59
+
60
+ begin
61
+ parser.parse!(args)
62
+ rescue OptionParser::InvalidOption => e
63
+ puts e.message
64
+ puts parser
65
+ exit GitXplorerExit::INVALID_OPTION
66
+ rescue OptionParser::InvalidArgument => e
67
+ puts e.message
68
+ puts parser
69
+ exit GitXplorerExit::INVALID_ARGUMENT
70
+ rescue OptionParser::MissingArgument => e
71
+ puts e.message
72
+ puts parser
73
+ exit GitXplorerExit::MISSING_ARGUMENT
74
+ rescue OptionParser::AmbiguousOption => e
75
+ puts e.message
76
+ puts parser
77
+ exit GitXplorerExit::AMBIGUOUS_ARGUMENT
78
+ end
79
+
80
+ if (!args.empty?)
81
+ puts parser
82
+ exit GitXplorerExit::EXTRA_ARGUMENTS
83
+ end
84
+
85
+ return options
86
+ end
87
+
88
+ begin
89
+ options = parse(ARGV)
90
+ rescue Interrupt
91
+ # Exit gracefully on ^C
92
+ exit GitXplorerExit::GOOD
93
+ end
94
+
95
+ begin
96
+ gitx = GitXplorer.new
97
+
98
+ djinni = Djinni.new
99
+ djinni.fallback = "git"
100
+ djinni.load_wishes(
101
+ "#{File.dirname(__FILE__)}/../lib/git_xplorer/wish"
102
+ )
103
+ djinni.prompt({"gitXplorer" => gitx}, "#{gitx.pwd}$ ".light_white)
104
+ rescue SystemExit
105
+ # Quite from djinni
106
+ # Exit gracefully
107
+ rescue Interrupt
108
+ # Exit gracefully on ^C
109
+ rescue Errno::EPIPE
110
+ # Do nothing. This can happen if piping to another program such as
111
+ # less. Usually if less is closed before we're done with STDOUT.
112
+ rescue GitXplorer::Error => e
113
+ puts e.message
114
+ exit GitXplorerExit::EXCEPTION
115
+ rescue Exception => e
116
+ $stderr.puts [
117
+ "Oops! Looks like an error has occured! If the error",
118
+ "persists, file a bug at:"
119
+ ].join(" ").wrap
120
+ $stderr.puts
121
+ $stderr.puts " https://gitlab.com/mjwhitta/git_xplorer/issues"
122
+ $stderr.puts
123
+ $stderr.puts [
124
+ "Maybe the message below will help. If not, you can use the",
125
+ "--verbose flag to get a backtrace."
126
+ ].join(" ").wrap
127
+ $stderr.puts
128
+
129
+ $stderr.puts e.message.white.on_red
130
+ if (options["verbose"])
131
+ e.backtrace.each do |line|
132
+ $stderr.puts line.light_yellow
133
+ end
134
+ end
135
+ exit GitXplorerExit::EXCEPTION
136
+ end
137
+ exit GitXplorerExit::GOOD
data/bin/gitx ADDED
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "djinni"
4
+ require "git_xplorer"
5
+ require "hilighter"
6
+ require "io/wait"
7
+ require "optparse"
8
+
9
+ class GitXplorerExit
10
+ GOOD = 0
11
+ INVALID_OPTION = 1
12
+ INVALID_ARGUMENT = 2
13
+ MISSING_ARGUMENT = 3
14
+ EXTRA_ARGUMENTS = 4
15
+ EXCEPTION = 5
16
+ AMBIGUOUS_ARGUMENT = 6
17
+ end
18
+
19
+ def parse(args)
20
+ options = Hash.new
21
+ options["verbose"] = false
22
+
23
+ info = [
24
+ "Drop into a shell-like environment that simulates a",
25
+ "filesystem. Easily navigate thru directories and browse all",
26
+ "files across all revisions."
27
+ ].join(" ")
28
+
29
+ parser = OptionParser.new do |opts|
30
+ opts.summary_width = 19
31
+
32
+ opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
33
+
34
+ opts.on("")
35
+
36
+ info.scan(/\S.{0,80}\S(?=\s|$)|\S+/).each do |line|
37
+ opts.on("#{line}")
38
+ end
39
+
40
+ opts.on("", "OPTIONS")
41
+
42
+ opts.on("-h", "--help", "Display this help message") do
43
+ puts opts
44
+ exit GitXplorerExit::GOOD
45
+ end
46
+
47
+ opts.on("--nocolor", "Disable colorized output") do
48
+ Hilighter.disable
49
+ end
50
+
51
+ opts.on(
52
+ "-v",
53
+ "--verbose",
54
+ "Show backtrace when error occurs"
55
+ ) do
56
+ options["verbose"] = true
57
+ end
58
+ end
59
+
60
+ begin
61
+ parser.parse!(args)
62
+ rescue OptionParser::InvalidOption => e
63
+ puts e.message
64
+ puts parser
65
+ exit GitXplorerExit::INVALID_OPTION
66
+ rescue OptionParser::InvalidArgument => e
67
+ puts e.message
68
+ puts parser
69
+ exit GitXplorerExit::INVALID_ARGUMENT
70
+ rescue OptionParser::MissingArgument => e
71
+ puts e.message
72
+ puts parser
73
+ exit GitXplorerExit::MISSING_ARGUMENT
74
+ rescue OptionParser::AmbiguousOption => e
75
+ puts e.message
76
+ puts parser
77
+ exit GitXplorerExit::AMBIGUOUS_ARGUMENT
78
+ end
79
+
80
+ if (!args.empty?)
81
+ puts parser
82
+ exit GitXplorerExit::EXTRA_ARGUMENTS
83
+ end
84
+
85
+ return options
86
+ end
87
+
88
+ begin
89
+ options = parse(ARGV)
90
+ rescue Interrupt
91
+ # Exit gracefully on ^C
92
+ exit GitXplorerExit::GOOD
93
+ end
94
+
95
+ begin
96
+ gitx = GitXplorer.new
97
+
98
+ djinni = Djinni.new
99
+ djinni.fallback = "git"
100
+ djinni.load_wishes(
101
+ "#{File.dirname(__FILE__)}/../lib/git_xplorer/wish"
102
+ )
103
+ djinni.prompt({"gitXplorer" => gitx}, "#{gitx.pwd}$ ".light_white)
104
+ rescue SystemExit
105
+ # Quite from djinni
106
+ # Exit gracefully
107
+ rescue Interrupt
108
+ # Exit gracefully on ^C
109
+ rescue Errno::EPIPE
110
+ # Do nothing. This can happen if piping to another program such as
111
+ # less. Usually if less is closed before we're done with STDOUT.
112
+ rescue GitXplorer::Error => e
113
+ puts e.message
114
+ exit GitXplorerExit::EXCEPTION
115
+ rescue Exception => e
116
+ $stderr.puts [
117
+ "Oops! Looks like an error has occured! If the error",
118
+ "persists, file a bug at:"
119
+ ].join(" ").wrap
120
+ $stderr.puts
121
+ $stderr.puts " https://gitlab.com/mjwhitta/git_xplorer/issues"
122
+ $stderr.puts
123
+ $stderr.puts [
124
+ "Maybe the message below will help. If not, you can use the",
125
+ "--verbose flag to get a backtrace."
126
+ ].join(" ").wrap
127
+ $stderr.puts
128
+
129
+ $stderr.puts e.message.white.on_red
130
+ if (options["verbose"])
131
+ e.backtrace.each do |line|
132
+ $stderr.puts line.light_yellow
133
+ end
134
+ end
135
+ exit GitXplorerExit::EXCEPTION
136
+ end
137
+ exit GitXplorerExit::GOOD
data/bin/gitxplorer ADDED
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "djinni"
4
+ require "git_xplorer"
5
+ require "hilighter"
6
+ require "io/wait"
7
+ require "optparse"
8
+
9
+ class GitXplorerExit
10
+ GOOD = 0
11
+ INVALID_OPTION = 1
12
+ INVALID_ARGUMENT = 2
13
+ MISSING_ARGUMENT = 3
14
+ EXTRA_ARGUMENTS = 4
15
+ EXCEPTION = 5
16
+ AMBIGUOUS_ARGUMENT = 6
17
+ end
18
+
19
+ def parse(args)
20
+ options = Hash.new
21
+ options["verbose"] = false
22
+
23
+ info = [
24
+ "Drop into a shell-like environment that simulates a",
25
+ "filesystem. Easily navigate thru directories and browse all",
26
+ "files across all revisions."
27
+ ].join(" ")
28
+
29
+ parser = OptionParser.new do |opts|
30
+ opts.summary_width = 19
31
+
32
+ opts.banner = "Usage: #{File.basename($0)} [OPTIONS]"
33
+
34
+ opts.on("")
35
+
36
+ info.scan(/\S.{0,80}\S(?=\s|$)|\S+/).each do |line|
37
+ opts.on("#{line}")
38
+ end
39
+
40
+ opts.on("", "OPTIONS")
41
+
42
+ opts.on("-h", "--help", "Display this help message") do
43
+ puts opts
44
+ exit GitXplorerExit::GOOD
45
+ end
46
+
47
+ opts.on("--nocolor", "Disable colorized output") do
48
+ Hilighter.disable
49
+ end
50
+
51
+ opts.on(
52
+ "-v",
53
+ "--verbose",
54
+ "Show backtrace when error occurs"
55
+ ) do
56
+ options["verbose"] = true
57
+ end
58
+ end
59
+
60
+ begin
61
+ parser.parse!(args)
62
+ rescue OptionParser::InvalidOption => e
63
+ puts e.message
64
+ puts parser
65
+ exit GitXplorerExit::INVALID_OPTION
66
+ rescue OptionParser::InvalidArgument => e
67
+ puts e.message
68
+ puts parser
69
+ exit GitXplorerExit::INVALID_ARGUMENT
70
+ rescue OptionParser::MissingArgument => e
71
+ puts e.message
72
+ puts parser
73
+ exit GitXplorerExit::MISSING_ARGUMENT
74
+ rescue OptionParser::AmbiguousOption => e
75
+ puts e.message
76
+ puts parser
77
+ exit GitXplorerExit::AMBIGUOUS_ARGUMENT
78
+ end
79
+
80
+ if (!args.empty?)
81
+ puts parser
82
+ exit GitXplorerExit::EXTRA_ARGUMENTS
83
+ end
84
+
85
+ return options
86
+ end
87
+
88
+ begin
89
+ options = parse(ARGV)
90
+ rescue Interrupt
91
+ # Exit gracefully on ^C
92
+ exit GitXplorerExit::GOOD
93
+ end
94
+
95
+ begin
96
+ gitx = GitXplorer.new
97
+
98
+ djinni = Djinni.new
99
+ djinni.fallback = "git"
100
+ djinni.load_wishes(
101
+ "#{File.dirname(__FILE__)}/../lib/git_xplorer/wish"
102
+ )
103
+ djinni.prompt({"gitXplorer" => gitx}, "#{gitx.pwd}$ ".light_white)
104
+ rescue SystemExit
105
+ # Quite from djinni
106
+ # Exit gracefully
107
+ rescue Interrupt
108
+ # Exit gracefully on ^C
109
+ rescue Errno::EPIPE
110
+ # Do nothing. This can happen if piping to another program such as
111
+ # less. Usually if less is closed before we're done with STDOUT.
112
+ rescue GitXplorer::Error => e
113
+ puts e.message
114
+ exit GitXplorerExit::EXCEPTION
115
+ rescue Exception => e
116
+ $stderr.puts [
117
+ "Oops! Looks like an error has occured! If the error",
118
+ "persists, file a bug at:"
119
+ ].join(" ").wrap
120
+ $stderr.puts
121
+ $stderr.puts " https://gitlab.com/mjwhitta/git_xplorer/issues"
122
+ $stderr.puts
123
+ $stderr.puts [
124
+ "Maybe the message below will help. If not, you can use the",
125
+ "--verbose flag to get a backtrace."
126
+ ].join(" ").wrap
127
+ $stderr.puts
128
+
129
+ $stderr.puts e.message.white.on_red
130
+ if (options["verbose"])
131
+ e.backtrace.each do |line|
132
+ $stderr.puts line.light_yellow
133
+ end
134
+ end
135
+ exit GitXplorerExit::EXCEPTION
136
+ end
137
+ exit GitXplorerExit::GOOD
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::InvalidRevision < GitXplorer::Error
2
+ def initialize(rev)
3
+ super("Invalid revision: #{rev}")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::NoChainingAllowed < GitXplorer::Error
2
+ def initialize
3
+ super("No chaining together shell commands!")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::NoFileOrDirectory < GitXplorer::Error
2
+ def initialize(dir)
3
+ super("No such file or directory: #{dir}")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::NoSemicolonsAllowed < GitXplorer::Error
2
+ def initialize
3
+ super("No semicolons allowed in shell commands!")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::NoSubshellsAllowed < GitXplorer::Error
2
+ def initialize
3
+ super("No subshells allowed in shell commands!")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::NotDirectory < GitXplorer::Error
2
+ def initialize(file)
3
+ super("Not a directory: #{file}")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class GitXplorer::Error::NotFile < GitXplorer::Error
2
+ def initialize(dir)
3
+ super("Not a file: #{dir}")
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class GitXplorer::Error < RuntimeError
2
+ end
3
+
4
+ require "git_xplorer/error/invalid_revision"
5
+ require "git_xplorer/error/no_file_or_directory"
6
+ require "git_xplorer/error/no_chaining_allowed"
7
+ require "git_xplorer/error/no_semicolons_allowed"
8
+ require "git_xplorer/error/no_subshells_allowed"
9
+ require "git_xplorer/error/not_directory"
10
+ require "git_xplorer/error/not_file"
@@ -0,0 +1,67 @@
1
+ class GitXplorer::GitObject::Directory < GitXplorer::GitObject
2
+ def absolute_path
3
+ return "" if (@parent.nil?)
4
+ return "#{super}/"
5
+ end
6
+
7
+ def add(path)
8
+ dir, _, file = path.partition("/")
9
+ if (file.nil? || file.empty?)
10
+ # Add file
11
+ file = GitXplorer::GitObject::File.new(dir, self)
12
+ @files[file.name] = file
13
+ else
14
+ # Add subdirectory
15
+ if (@directories[dir].nil?)
16
+ directory = GitXplorer::GitObject::Directory.new(
17
+ dir,
18
+ self
19
+ )
20
+ @directories[dir] = directory
21
+ end
22
+ @directories[dir].add(file)
23
+ end
24
+ end
25
+
26
+ def children
27
+ if (@kids.nil?)
28
+ # Initialize
29
+ @kids = Array.new
30
+
31
+ # Get child directories first
32
+ @kids.concat(
33
+ @directories.values.sort do |a, b|
34
+ a.name.downcase <=> b.name.downcase
35
+ end
36
+ )
37
+
38
+ # Get child files
39
+ @kids.concat(
40
+ @files.values.sort do |a, b|
41
+ a.name.downcase <=> b.name.downcase
42
+ end
43
+ )
44
+ end
45
+
46
+ return @kids
47
+ end
48
+
49
+ def desc
50
+ return "Directory"
51
+ end
52
+
53
+ def initialize(name, parent)
54
+ super(name.gsub(%r{/+$}, ""), parent)
55
+ @directories = Hash.new
56
+ @files = Hash.new
57
+ end
58
+
59
+ def tab_complete(color = false)
60
+ color ||= false
61
+ return {"#{@name}/" => desc}
62
+ end
63
+
64
+ def to_s
65
+ return "#{@name}/"
66
+ end
67
+ end