git-scripts 0.8.1 → 0.9.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 +4 -4
- data/lib/git.rb +8 -9
- data/lib/helpers.rb +0 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca7a07fad736def34f5e2331b252ac72a796dee71947c4e5335037228c9d6707
|
4
|
+
data.tar.gz: 45d9dc64adf34ecabb851267ca347c7f4cd550859666f4acfc50f0f0e8527245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbae689c36738b248565eba9d7dbfeb045f543bda1367f6340eede24eff9a0bdaf1ff39826509e6c1fa684abb8726702b1eb7eae8b90666f8a55d6f20ddc0655
|
7
|
+
data.tar.gz: 1cf62bf2b3a69d7f540e11f5cd26a1d3bf58711cf5e2049536ae05f5031f3f7b2eb8d80eeb11289144aeaecabf6aff60758645accdf403195c4da7fac9df7815
|
data/lib/git.rb
CHANGED
@@ -91,7 +91,7 @@ module Git
|
|
91
91
|
# Returns an array of all branch names that have have been merged into the
|
92
92
|
# specified branch
|
93
93
|
def self.merged_branches(into_branch='master')
|
94
|
-
`git branch --merged #{into_branch} -a`.
|
94
|
+
`git branch --merged #{into_branch.shellescape} -a`.
|
95
95
|
split("\n").
|
96
96
|
map {|branch| branch.gsub('*','').strip.sub('remotes/','')}
|
97
97
|
end
|
@@ -107,8 +107,7 @@ module Git
|
|
107
107
|
|
108
108
|
# Returns the name of the currently checked out branch, or nil if detached.
|
109
109
|
def self.current_branch()
|
110
|
-
|
111
|
-
ref.split('/').last
|
110
|
+
`git symbolic-ref -q --short HEAD`.strip
|
112
111
|
end
|
113
112
|
|
114
113
|
# Deletes the current branch. For cleaning up after errors.
|
@@ -123,12 +122,12 @@ module Git
|
|
123
122
|
|
124
123
|
Git::switch_branch(devBranch)
|
125
124
|
|
126
|
-
`git branch -d #{branch}`.strip
|
125
|
+
`git branch -d #{branch.shellescape}`.strip
|
127
126
|
end
|
128
127
|
|
129
128
|
# Returns the SHA1 hash that the specified branch or symbol points to
|
130
129
|
def self.branch_hash(branch)
|
131
|
-
`git rev-parse --verify --quiet
|
130
|
+
`git rev-parse --verify --quiet #{branch.shellescape} 2>/dev/null`.strip
|
132
131
|
end
|
133
132
|
|
134
133
|
# Returns formatted string containing:
|
@@ -139,7 +138,7 @@ module Git
|
|
139
138
|
def self.branch_info(branch)
|
140
139
|
# branch info format: hash author (relative date)
|
141
140
|
format = "%h %an %Cgreen(%ar)%Creset"
|
142
|
-
branch_info = `git show -s --pretty
|
141
|
+
branch_info = `git show -s --pretty=#{format.shellescape} #{branch.shellescape}`.strip
|
143
142
|
simple_branch = branch.sub('origin/', '')
|
144
143
|
sprintf "%-30s %s", simple_branch, branch_info
|
145
144
|
end
|
@@ -149,7 +148,7 @@ module Git
|
|
149
148
|
safe_command = command.gsub(/[^[:print:]]+/,' ')
|
150
149
|
puts "> " + safe_command
|
151
150
|
unless system(command)
|
152
|
-
puts highlight("\nERROR: failed on #{safe_command}
|
151
|
+
puts highlight("\nERROR: failed on #{safe_command}.")
|
153
152
|
puts "\nWould have run:"
|
154
153
|
commands.each do |command|
|
155
154
|
puts "# " + command.gsub(/[^[:print:]]+/,' ')
|
@@ -244,7 +243,7 @@ module Git
|
|
244
243
|
def self.submodules_update(mode = "")
|
245
244
|
# capture only the path, not the newline
|
246
245
|
basedir = `git rev-parse --show-toplevel`.split("\n").first
|
247
|
-
command = "cd #{basedir} && git submodule --quiet update --init --recursive"
|
246
|
+
command = "cd #{basedir.shellescape} && git submodule --quiet update --init --recursive"
|
248
247
|
|
249
248
|
if mode == "get"
|
250
249
|
return command
|
@@ -257,7 +256,7 @@ module Git
|
|
257
256
|
# Returns the commit message from the given commit hash or branch name
|
258
257
|
#
|
259
258
|
def self.commit_message(ref)
|
260
|
-
`git log -1 --format="%B" #{ref}`.strip
|
259
|
+
`git log -1 --format="%B" #{ref.shellescape}`.strip
|
261
260
|
end
|
262
261
|
|
263
262
|
def self.git_dir()
|
data/lib/helpers.rb
CHANGED
@@ -104,10 +104,6 @@ def require_argument(program, command = nil, min = 2, max = 2)
|
|
104
104
|
if (ARGV.length < min)
|
105
105
|
help.call "Missing argument. This command requires exactly #{min} arguments."
|
106
106
|
end
|
107
|
-
|
108
|
-
if (ARGV.last !~ /^[a-zA-z0-9-]+$/)
|
109
|
-
help.call "Invalid branch name: '#{ARGV.last}'"
|
110
|
-
end
|
111
107
|
end
|
112
108
|
|
113
109
|
##
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Beardsley
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2019-
|
16
|
+
date: 2019-06-28 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: bundler
|
@@ -35,14 +35,14 @@ dependencies:
|
|
35
35
|
requirements:
|
36
36
|
- - "~>"
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: '4.
|
38
|
+
version: '4.0'
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
43
|
- - "~>"
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '4.
|
45
|
+
version: '4.0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: json
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|