t1k 1.0.1 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e0106184b19bc3354aaa110c345d1697e83cae3
4
- data.tar.gz: 5617aa9c735bbf65344e7a0db88a9a8e4588930b
3
+ metadata.gz: 4fd44cf6d6cfbb3a0c4c6a165465859d7952fbdf
4
+ data.tar.gz: 46f89bbf15ce26413c47e1263123f5b6602ee706
5
5
  SHA512:
6
- metadata.gz: 3d6185418e175014deb8a1d489a82c9975d61d60ba511359314f9828efe85c4aef3e9baf4928a080841e185b83a9820b016d9cefadc7b11ff090e5fbc6fb64cd
7
- data.tar.gz: 20b78b6644732410b078c3f3e5a1c163c843c41fa79d9d289aa9306149a2cc29687f16ad0985494c0f3f291f3fbe57aa36213313519b9e1a415d2b2099b92154
6
+ metadata.gz: 79dbbb5194ee2a45c411b603d3d2c784cc0416327b10a1bbd30858a6b234be497bdd113e34f444b51bc7a0c402f44fb3815d06c6a01731418b7b7aa741566942
7
+ data.tar.gz: 847bb324d970a5fc9cc1297a43cd2bc8f7849539006ca1e2ed11e6fd23d4779f47d85af62bc0119cfb0f151e2dc226cb051e41cbe82ffd4db6d1bce95182aa18
data/lib/t1k.rb CHANGED
@@ -27,9 +27,16 @@ module T1k
27
27
 
28
28
  def self.hack url_card
29
29
  card = tracker.get_card(url_card)
30
- issue = repository.get_issue(repository.create_issue(card.name).html_url)
31
- tracker.update_card(card, issue)
32
- puts "Card ##{issue.code} created and tracked"
33
- issue.code
30
+
31
+ existent_issue_match = card.name.match /^\[#([0-9]*)\]/
32
+ existent_issue_number = existent_issue_match[1] if existent_issue_match.present?
33
+
34
+ issue = existent_issue_number.present? ? repository.get_issue(existent_issue_number).html_url : repository.create_issue(card.name).html_url
35
+
36
+ issue_number = repository.get_issue_number(issue)
37
+ tracker.update_card(card, issue_number) if existent_issue_number.nil?
38
+
39
+ puts "Card ##{issue_number.code} created and tracked"
40
+ issue_number.code
34
41
  end
35
42
  end
@@ -37,7 +37,18 @@ module T1k
37
37
  end
38
38
  end
39
39
 
40
- def self.get_issue html_url
40
+ def self.get_issue issue_number
41
+ begin
42
+ puts "Recovering existent issue"
43
+ github_auth = ::Github.new(oauth_token: self.oauth_token)
44
+ issue = github_auth.issues.get user: self.user, repo: self.repo, number: issue_number
45
+ issue
46
+ rescue
47
+ raise 'Issue not recovered'
48
+ end
49
+ end
50
+
51
+ def self.get_issue_number html_url
41
52
  code = html_url[html_url.rindex('/')+1..html_url.size]
42
53
  Issue.new(code, "Link to code: [#{code}](#{html_url})")
43
54
  end
@@ -5,7 +5,7 @@ module T1k
5
5
  @@adapter = T1k::Repositories::Github # default adapter
6
6
 
7
7
  class << self
8
- delegate :create_issue, :get_issue, to: @@adapter
8
+ delegate :create_issue, :get_issue, :get_issue_number, to: @@adapter
9
9
  end
10
10
 
11
11
  def self.setup &block
@@ -1,3 +1,3 @@
1
1
  module T1k
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.6"
3
3
  end
@@ -9,6 +9,12 @@ namespace :t1k do
9
9
 
10
10
  system 'git checkout master'
11
11
  system 'git pull --rebase origin master'
12
- system "git checkout -b #{code_card}"
12
+ existent_branch = `git branch --list #{code_card}`
13
+
14
+ if existent_branch.present?
15
+ system "git checkout #{code_card}"
16
+ else
17
+ system "git checkout -b #{code_card}"
18
+ end
13
19
  end
14
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t1k
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Maia