patchy 1.0.0b1
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.
- data/LICENSE +19 -0
- data/README.md +53 -0
- data/bin/patchy +54 -0
- data/lib/patchy/version.rb +3 -0
- metadata +72 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 David Trasbo
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Patchy
|
2
|
+
|
3
|
+
Small script streamlining the process of submitting patches for Rails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install patchy --pre
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
### Starting
|
12
|
+
|
13
|
+
To start producing a patch for a ticket:
|
14
|
+
|
15
|
+
patchy 1234
|
16
|
+
|
17
|
+
In this case `1234` is the number of the ticket you want to work on. Patchy
|
18
|
+
assumes you want to base your patch on the `master` branch. If not you need to
|
19
|
+
specify it as the second argument:
|
20
|
+
|
21
|
+
patchy 1234 2-3-stable
|
22
|
+
|
23
|
+
What this will do is to to check out the base branch (`master` or what you
|
24
|
+
specify) and then create a `1234` branch in this case.
|
25
|
+
|
26
|
+
### Finishing
|
27
|
+
|
28
|
+
When you've made your changes and staged them (with `git add`):
|
29
|
+
|
30
|
+
patchy "Fix a critical bug"
|
31
|
+
|
32
|
+
Again, if your base branch is not master, specify it as the second argument:
|
33
|
+
|
34
|
+
patchy "Add a cool feature" 2-3-stable
|
35
|
+
|
36
|
+
What this will do is commit the staged changes, check out the base branch, do a
|
37
|
+
`git pull`, check out your ticket branch, rebase it based on the base branch,
|
38
|
+
and create a patch.
|
39
|
+
|
40
|
+
## Notes
|
41
|
+
|
42
|
+
One thing to note is that Patchy will append `[#1234 state:committed]` to the
|
43
|
+
commit message. Patchy shows you which commands it runs and asks you to approve
|
44
|
+
the output of certain critical commands before moving on.
|
45
|
+
|
46
|
+
I encourage you to take a look at the source code (in `bin/patchy`). It's only
|
47
|
+
54 lines "long" and helps you understand what exactly Patchy does for you.
|
48
|
+
|
49
|
+
## Copyright
|
50
|
+
|
51
|
+
Copyright (c) 2010 David Trasbo
|
52
|
+
|
53
|
+
Patchy is released under the MIT License. See `LICENSE` for details.
|
data/bin/patchy
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def run(command)
|
4
|
+
headline = "Running: #{command}"
|
5
|
+
puts headline
|
6
|
+
puts '=' * headline.length
|
7
|
+
`#{command}`
|
8
|
+
puts
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_and_approve(command)
|
12
|
+
run(command)
|
13
|
+
print('Approve? (Y/n) ')
|
14
|
+
input = gets
|
15
|
+
if input != $/ && input.chomp.downcase != 'y'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
puts
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_branch
|
22
|
+
`git branch`.split($/).select do |line|
|
23
|
+
line =~ /^\*/
|
24
|
+
end.first.delete('* ')
|
25
|
+
end
|
26
|
+
|
27
|
+
base_branch = ARGV[1] || 'master'
|
28
|
+
|
29
|
+
if ARGV[0] =~ /^\d+$/
|
30
|
+
ticket = ARGV[0]
|
31
|
+
|
32
|
+
unless base_branch == current_branch
|
33
|
+
run("git checkout #{base_branch}")
|
34
|
+
end
|
35
|
+
run("git checkout -b #{ticket}")
|
36
|
+
else
|
37
|
+
message = ARGV[0]
|
38
|
+
ticket = current_branch
|
39
|
+
|
40
|
+
ARGV.clear
|
41
|
+
|
42
|
+
run("git commit -m \"#{message} [##{ticket} state:committed]\"")
|
43
|
+
run("git checkout #{base_branch}")
|
44
|
+
run_and_approve("git pull")
|
45
|
+
run("git checkout #{ticket}")
|
46
|
+
run_and_approve("git rebase #{base_branch}")
|
47
|
+
run("git format-patch #{base_branch} --stdout > #{ticket}.diff")
|
48
|
+
|
49
|
+
headline = "Patch saved to: #{ticket}.diff"
|
50
|
+
puts
|
51
|
+
puts headline
|
52
|
+
puts '=' * headline.length
|
53
|
+
puts File.read("#{ticket}.diff")
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: patchy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 415574164
|
5
|
+
prerelease: true
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0b1
|
10
|
+
version: 1.0.0b1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- David Trasbo
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-28 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: me@dtrasbo.com
|
24
|
+
executables:
|
25
|
+
- patchy
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/patchy/version.rb
|
32
|
+
- bin/patchy
|
33
|
+
- README.md
|
34
|
+
- LICENSE
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/dtrasbo/patchy
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 25
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 3
|
62
|
+
- 1
|
63
|
+
version: 1.3.1
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.3.7
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Small script streamlining the process of submitting patches for Rails.
|
71
|
+
test_files: []
|
72
|
+
|