patchr 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/bin/patchr +27 -13
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/patchr CHANGED
@@ -3,22 +3,11 @@ require 'lighthouse-api'
3
3
 
4
4
  command, *args = ARGV
5
5
 
6
- if command == "clean"
7
- puts "clean current branch"
8
- branch = `ref=$(git symbolic-ref HEAD 2> /dev/null); echo ${ref#refs/heads/}`
9
- unless branch == "master"
10
- `git checkout master`
11
- `git branch -D #{branch}`
12
- end
13
- elsif command == "apply"
14
-
15
- ticket_id = args[0]
16
-
6
+ def find_attachment(ticket_id)
17
7
  unless ticket_id
18
8
  puts "Supply ticket id"
19
9
  exit
20
10
  end
21
- puts "apply issue #{ticket_id}"
22
11
 
23
12
  Lighthouse.account = "rails"
24
13
  ticket = Lighthouse::Ticket.find(ticket_id, :params => { :project_id => 8994 } )
@@ -40,13 +29,38 @@ elsif command == "apply"
40
29
  else
41
30
  attachment.first
42
31
  end
32
+ end
33
+
34
+ def retrieve_patch_file(ticket_id, attachment)
35
+ patch_file = "/tmp/#{ticket_id}-#{attachment.filename}"
36
+ `curl -kL #{attachment.url} > #{patch_file}`
37
+ patch_file
38
+ end
39
+
40
+ if command == "clean"
41
+ puts "clean current branch"
42
+ branch = `ref=$(git symbolic-ref HEAD 2> /dev/null); echo ${ref#refs/heads/}`
43
+ unless branch == "master"
44
+ `git checkout master`
45
+ `git branch -D #{branch}`
46
+ end
47
+ elsif command == "view"
48
+ ticket_id = args[0]
49
+ attachment = find_attachment(ticket_id)
50
+ patch_file = retrieve_patch_file(ticket_id, attachment)
51
+ `mate #{patch_file}`
52
+ elsif command == "apply"
53
+ ticket_id = args[0]
54
+
55
+ puts "applying issue #{ticket_id}"
43
56
 
44
57
  # Create local branch and run tests
45
58
  puts "Applying #{attachment.filename} of issue #{ticket_id}"
46
59
  `git checkout master`
47
60
  `git pull origin master`
48
61
  `git checkout -b #{ticket_id}-#{attachment.filename}`
49
- `git apply #{attachment.url}`
62
+ patch_file = retrieve_patch_file(ticket_id, attachment)
63
+ `git apply #{patch_file}`
50
64
  `rake`
51
65
  else
52
66
  if command.blank?
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeroen van Dijk