gitjira 0.0.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d277b83f7b4c7e19dd4c37981ed4bf2dd17ba9b4
4
- data.tar.gz: 6eaa7a36b90a0326dfb782c3142d8dc6d6366d48
3
+ metadata.gz: 4352b0c24da71ed1886cce9a72e0a81a54b401e9
4
+ data.tar.gz: 100b0d5bdeb9bb956bc7d2b99d68048d27a2a00a
5
5
  SHA512:
6
- metadata.gz: 0dbc4c743ff1cc5823340739f9af45bbfc971441adc232c64124d8bba8fc7323c25663dd08ac129770c6dc52a02d3d5d49c5faf563fd60a2da5305706c00896b
7
- data.tar.gz: 1699a939ba23a9826ea6c97a4d3706dc38abf756984b6e0f4fa0993232e23ceb4733921c86eba54a6d02b8753417eebbc922d5bf5086cad0a24b545ca9953cd2
6
+ metadata.gz: a76e3a6d48d2625d7606279300a1e3728f72f71ffd30ec03ee34e6f1c8de6530dd1c3c7e57c6cede18d2de20892859fa9b95913a9bc72bdf5cb18b4c8ce01b11
7
+ data.tar.gz: 892addae5df559e8fabf8a7ac10ea48757356262c3692f2682a47e88431b5b336175155e58cccad7aa6299be1075ac1db72314c463fbd6bf62b8cc0731d7b0e2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitjira (0.0.2)
4
+ gitjira (0.1.0)
5
5
  highline
6
6
  rest-client (~> 1.6)
7
7
 
data/README.md CHANGED
@@ -1,42 +1,68 @@
1
1
  # gitjira
2
2
 
3
- Git JIRA is an extension that combines feature or all other type of branches
3
+ Git JIRA is an extension that combines feature, or all other type of branches,
4
4
  with JIRA issues. It shows the current status and the summary of the issue.
5
5
 
6
6
  In order to be able to combine branches the branch name must include the following
7
7
  string _PROJECTKEY-###_
8
8
 
9
- Examples if the project key is _PROJ_ and the issue number _123_
9
+ Examples if the project key is _PROJ_ and the issue number is _123_
10
10
 
11
- features/PROJ-123_some_description
12
- someprefix/PROJ-123_some_description
13
11
  PROJ-123
14
12
  PROJ-123_description
13
+ features/PROJ-123_some_description
14
+ someprefix/PROJ-123-some_description
15
15
 
16
16
  ## Installation
17
17
 
18
18
  Install via rubygems.org:
19
19
 
20
20
  $ gem install gitjira
21
- or with rvm
21
+ or with global via rvm
22
22
  $ rvm @global do gem install gitjira
23
23
 
24
24
  ## Setup:
25
25
 
26
- $ git jira init
26
+ $ git-jira init
27
27
  JIRA host (e.g. https://jira.example.org): http://www.example.org/jira
28
28
  Your JIRA username : johnny
29
29
  Your JIRA password : ************
30
30
  Related JIRA project key (e.g. PROJ) : PROJ
31
31
 
32
+ If you want update the configuration file, e.g. changing the host, you can
33
+ update directly the .git/config file or via the following command:
34
+
35
+ $ git-jira init -f # or --force
32
36
 
33
- ## Example Scenario - Feature Branches:
34
37
 
35
- $ git jira list
38
+ ## Example Scenario #1 - List branch information that have related JIRA issues:
39
+
40
+ $ git-jira list
36
41
  Open 0% done PROJ-123 - Implement some new feature
37
42
  Resolved 100% done PROJ-20 - And yet another feature
38
43
  Resolved 42% done PROJ-16 - Add /features page
39
44
 
45
+ ## Exampel Scenario #2 - Get information about the current branch
46
+
47
+ $ git-jira describe
48
+ => Add /features page <=
49
+
50
+ Issue Key...........: PROJ-123
51
+ Type................: New Feature
52
+ Status..............: Resolved
53
+ Progress............: 42.0 %
54
+ Estimated Work......: 1d
55
+ Remaining Work......: 4h 35m
56
+ Resolution..........: Fixed
57
+ Priority............: Major
58
+ Assignee............: Me
59
+ Reporter............: Me
60
+ Created At..........: 2013-05-26 13:09:17 +0200
61
+ Updated At..........: 2013-06-20 23:21:18 +0200
62
+ Fix Version.........: v1.2.0 (2013-06-30),
63
+
64
+ Add a page that list all features.
65
+
40
66
  ## Tips & Tricks
41
67
 
42
68
  Use aliases to be even more efficient, e.g. add 'alias jl = jira list' to your global ~/.gitconfig
@@ -50,6 +76,8 @@ Use aliases to be even more efficient, e.g. add 'alias jl = jira list' to your g
50
76
 
51
77
  ## Contributing
52
78
 
79
+ Please contribute and help to make this tool even better.
80
+
53
81
  1. Fork it
54
82
  2. Create your feature branch (`git checkout -b my-new-feature`)
55
83
  3. Commit your changes (`git commit -am 'Add some feature'`)
data/bin/git-jira CHANGED
@@ -22,6 +22,7 @@ opt_parser = OptionParser.new do |opt|
22
22
  opt.separator "Commands"
23
23
  opt.separator " init: setup the current repository to be able to connect to a JIRA project"
24
24
  opt.separator " list: returns a list of branches with related issue information"
25
+ opt.separator " describe: verbose issue information related to the current branch"
25
26
  opt.separator ""
26
27
 
27
28
  opt.on("-h", "--help", "help") do
@@ -54,6 +55,8 @@ when "list"
54
55
  rescue => e
55
56
  STDERR.puts "[ERROR] Not able to fetch feature branch information from JIRA, through exception: #{e}"
56
57
  end
58
+ when "describe"
59
+ Gitjira::InformationFetching.describe
57
60
  else
58
61
  STDOUT.puts opt_parser
59
62
  end
@@ -1,8 +1,6 @@
1
1
  class Gitjira::InformationFetching
2
2
 
3
3
  def self.branches
4
- jira_url = "#{Gitjira::InformationFetching.host}rest/api/2/issue/"
5
- credentials = Gitjira::InformationFetching.credentials
6
4
  project_key = Gitjira::InformationFetching.project_key
7
5
  branches = `git branch -a`.split("\n")
8
6
  issues = Array.new
@@ -16,10 +14,6 @@ class Gitjira::InformationFetching
16
14
  end
17
15
 
18
16
  if fetch
19
- response = RestClient::Resource.new("#{jira_url}#{branch}", {
20
- :headers => { "Authorization" => "Basic #{credentials}" }
21
- }).get
22
- json = JSON.parse(response)
23
17
  if json['fields']['progress']['percent']
24
18
  puts sprintf "%-12s %3.0f%s\t%-14s - %s",
25
19
  json['fields']['status']['name'],
@@ -38,16 +32,102 @@ class Gitjira::InformationFetching
38
32
  return nil
39
33
  end
40
34
 
41
- def self.project_key
42
- `git config --local --get gitjira.projectkey`.chomp
35
+ def self.describe
36
+ issue = self.extract_issue
37
+ if issue
38
+ issue_info = self.fetch_issue_json(issue)
39
+ if issue_info
40
+ fields = issue_info['fields']
41
+
42
+ puts "=> #{fields['summary']} <="
43
+ puts ""
44
+ puts "Issue Key...........: #{issue_info['key']}"
45
+ puts "Type................: #{fields['issuetype']['name']}"
46
+ puts "Status..............: #{fields['status'] ? fields['status']['name'] : 'None'}"
47
+ if fields['progress'] and fields['progress']['percent']
48
+ puts "Progress............: #{fields['progress']['percent'].round(2)} %"
49
+ end
50
+ if fields['timetracking'] and fields['timetracking']['originalEstimate'] and fields['timetracking']['remainingEstimate']
51
+ puts "Estimated Work......: #{fields['timetracking']['originalEstimate']}"
52
+ puts "Remaining Work......: #{fields['timetracking']['remainingEstimate']}"
53
+ end
54
+ puts "Resolution..........: #{fields['resolution'] ? fields['resolution']['name'] : 'None'}"
55
+ puts "Priority............: #{fields['priority']['name']}"
56
+ puts "Assignee............: #{self.extract_person(fields['assignee'])}"
57
+ puts "Reporter............: #{self.extract_person(fields['reporter'])}"
58
+ puts "Created At..........: #{self.date_formatter(fields['created'])}"
59
+ puts "Updated At..........: #{self.date_formatter(fields['updated'])}"
60
+ puts "Fix Version.........: #{self.extract_versions(fields['fixVersions'])}"
61
+
62
+ if fields['description']
63
+ puts ""
64
+ puts "#{fields['description']}"
65
+ end
66
+ else
67
+ puts "[Error] Not able to extract issue information of '#{issue}'"
68
+ end
69
+ else
70
+ puts "[Warning] You are currently in no branch that is related to an issue."
71
+ end
43
72
  end
44
73
 
45
- def self.credentials
46
- `git config --local --get gitjira.credentials`.chomp
74
+ def self.date_formatter(date)
75
+ DateTime.parse(date).strftime("%Y-%m-%d %H:%M:%S %z")
76
+ end
77
+
78
+ def self.extract_person(person_object)
79
+ me_email = `git config --get user.email`.chomp
80
+ if me_email and person_object and me_email.eql?(person_object['emailAddress'])
81
+ "Me"
82
+ else
83
+ "#{person_object['displayName']} <#{person_object['emailAddress']}>"
84
+ end
85
+ end
86
+
87
+ def self.extract_versions(version_array)
88
+ if version_array and version_array.kind_of?(Array)
89
+ versions = ""
90
+ version_array.each do |version|
91
+ versions = "#{version['name']} (#{version['releaseDate']}), #{versions}"
92
+ end
93
+ versions
94
+ else
95
+ ""
96
+ end
97
+ end
98
+
99
+ def self.extract_issue(branch_name = nil)
100
+ branch_name = Gitjira::InformationFetching.current_branch if branch_name.nil?
101
+ project_key = Gitjira::InformationFetching.project_key
102
+ branch_name[/#{project_key}-\d+/]
103
+ end
104
+
105
+ def self.current_branch
106
+ `git branch --no-color | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
107
+ end
108
+
109
+ def self.project_key
110
+ `git config --local --get gitjira.projectkey`.chomp
47
111
  end
48
112
 
49
113
  def self.host
50
- `git config --local --get gitjira.host`.chomp
114
+ `git config --local --get gitjira.host`.chomp
115
+ end
116
+
117
+ private
118
+ def self.fetch_issue_json(issue_name)
119
+ jira_url = "#{Gitjira::InformationFetching.host}rest/api/2/issue/"
120
+ credentials = Gitjira::InformationFetching.credentials
121
+
122
+ response = RestClient::Resource.new("#{jira_url}#{issue_name}", {
123
+ :headers => { "Authorization" => "Basic #{credentials}" }
124
+ }).get
125
+ json = JSON.parse(response)
126
+ json
127
+ end
128
+
129
+ def self.credentials
130
+ `git config --local --get gitjira.credentials`.chomp
51
131
  end
52
132
 
53
133
  end
@@ -1,3 +1,3 @@
1
1
  module Gitjira
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitjira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Oberhauser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-21 00:00:00.000000000 Z
11
+ date: 2013-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client