gitjira 0.2.0 → 0.3.0

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: 6df10c782e1e083a1e4b765f5ba5151e6487ea25
4
- data.tar.gz: dba31206fe7605e1c7987c87faccc03bcf52f85f
3
+ metadata.gz: 81c1bc701b41a93ef30dcee92ac3bdb2444e0126
4
+ data.tar.gz: 9cf5d0e5f6dadbe1e7670a290c60156f289e8f87
5
5
  SHA512:
6
- metadata.gz: 2071da8a3b4178f6f2ea18aa201f4ee8913a976314de85fd5671821c92eda4efdbd06913d2f37b5983c0e0840b2f8ac9697a4ca42a4da33325990e987d02635f
7
- data.tar.gz: 8094dc7d078a3c692e9744ca1d4340e8f904b02f511128d71cf55e8dadbf82b604351f2b5d3d094f0a4fe6324c7ec314ee111fb73515ecf1eb491da2bc51dab2
6
+ metadata.gz: b0521a9764b17f453add243ca20c59ee78db0c0586e5332e6350e1702e4ad0b5b3dea52c99496fc63485f14fcb5881b91067b08fa337e648fa53bc43fb0b21f6
7
+ data.tar.gz: 2f6d00ac16bda851b1d7093122405e33cad4531ed6686d4ace566848132902c2f4ad3113573c9387b120a63e6dbf8c66477d27b35d2f93346297d5390e628d59
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitjira (0.2.0)
4
+ gitjira (0.3.0)
5
5
  highline
6
6
  rest-client (~> 1.6)
7
7
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 TODO: Write your name
1
+ Copyright (c) 2013 Sigimera Ltd.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -24,7 +24,7 @@ Install via rubygems.org:
24
24
 
25
25
  ## Setup:
26
26
 
27
- $ git-jira init
27
+ $ git-jira init # or gj init
28
28
  JIRA host (e.g. https://jira.example.org): http://www.example.org/jira
29
29
  Your JIRA username : johnny
30
30
  Your JIRA password : ************
@@ -33,19 +33,27 @@ Install via rubygems.org:
33
33
  If you want update the configuration file, e.g. changing the host, you can
34
34
  update directly the .git/config file or via the following command:
35
35
 
36
- $ git-jira init -f # or --force
36
+ $ git-jira init -f # or --force or gj init
37
37
 
38
38
 
39
- ## Example Scenario #1 - List branch information that have related JIRA issues:
39
+ Check if the configuration was stored correctly.
40
40
 
41
- $ git-jira list
41
+ $ git-jira config # or gj config
42
+ JIRA Host...........: https://www.example.org/jira
43
+ JIRA Project Key....: PROJ
44
+ JIRA Username.......: johnny
45
+
46
+
47
+ ## Example #1 - List branch information that have related JIRA issues:
48
+
49
+ $ git-jira list # or gj list or git-jira or gj
42
50
  Open 0% done PROJ-123 - Implement some new feature
43
51
  Resolved 100% done PROJ-20 - And yet another feature
44
52
  Resolved 42% done PROJ-16 - Add /features page
45
53
 
46
- ## Exampel Scenario #2 - Get information about the current branch
54
+ ## Exampel #2 - Get information about the current branch
47
55
 
48
- $ git-jira describe
56
+ $ git-jira describe # or gj describe
49
57
  => Add /features page <=
50
58
 
51
59
  Issue Key...........: PROJ-123
@@ -64,11 +72,11 @@ update directly the .git/config file or via the following command:
64
72
 
65
73
  Add a page that lists all features.
66
74
 
67
- ## Exampel Scenario #3 - Get information about a specific issue
75
+ ## Exampel #3 - Get information about a specific issue
68
76
 
69
77
  Get information about a specific issue that must not be available as branch.
70
78
 
71
- $ git-jira describe -i 123 # or git-jira describe -i PROJ-123
79
+ $ git-jira describe -i 123 # or git-jira describe -i PROJ-123 or gj describe -i PROJ-123
72
80
  => Add /features page <=
73
81
 
74
82
  Issue Key...........: PROJ-123
@@ -14,25 +14,28 @@ rescue LoadError => e
14
14
  exit
15
15
  end
16
16
 
17
- options = { :force => false }
17
+ options = { :force => false, :issue => nil }
18
18
 
19
19
  opt_parser = OptionParser.new do |opt|
20
20
  opt.banner = "Usage: git-jira [COMMANDS] [OPTIONS]"
21
+ opt.separator "Alternative: gj [COMMANDS] [OPTIONS]"
21
22
  opt.separator ""
22
23
  opt.separator "Commands"
23
- opt.separator " init [-f | --force]: setup the current repository to be able to connect to a JIRA project"
24
- opt.separator " list: returns a list of branches with related issue information"
25
- opt.separator " describe [-i | --issue]: verbose issue information related to the current branch or specified issue"
24
+ opt.separator " init [-f | --force] setup the current repository to be able to connect to a JIRA project"
25
+ opt.separator " config output the configuration fields as specified under .git/config"
26
+ opt.separator " list returns a list of branches with related issue information"
27
+ opt.separator " describe [-i | --issue] verbose issue information related to the current branch or specified issue"
26
28
  opt.separator ""
29
+ opt.separator "Options"
27
30
 
28
31
  opt.on("-h", "--help", "help") do
29
32
  STDOUT.puts opt_parser
30
- exit
33
+ exit 0
31
34
  end
32
35
 
33
36
  opt.on("-v", "--version", "print out current Version number") do
34
37
  STDOUT.puts "gitjira-#{Gitjira::VERSION}"
35
- exit
38
+ exit 0
36
39
  end
37
40
 
38
41
  opt.on("-f", "--force", "force overwrite of .git/config [gitjira] block") do
@@ -42,29 +45,44 @@ opt_parser = OptionParser.new do |opt|
42
45
  opt.on("-i", "--issue [ISSUE]", "specify an issue number, e.g. PROJ-123 or 123") do |i|
43
46
  options[:issue] = i if i
44
47
  end
48
+
49
+ opt.separator ""
50
+ opt.separator "Copyright (C) 2013 Sigimera Ltd."
45
51
  end
46
52
 
47
53
  opt_parser.parse!
48
54
 
49
- case ARGV[0]
50
- when "init"
51
- Gitjira::Setup.init(options[:force])
52
- when "list"
55
+ def list
53
56
  unless Gitjira::Setup.setup?
54
- STDERR.puts "[SETUP] This repository is not setup correcly, please execute: `git-jira init`"
55
- exit
57
+ STDERR.puts "[SETUP] This repository is not setup, please execute: `git-jira init`"
58
+ exit 1
56
59
  end
57
60
  begin
58
- Gitjira::InformationFetching.branches
61
+ exit Gitjira::InformationFetching.branches
59
62
  rescue => e
60
63
  STDERR.puts "[ERROR] Not able to fetch issue information from JIRA, through exception: #{e}"
64
+ exit 2
61
65
  end
66
+ end
67
+
68
+ case ARGV[0]
69
+ when "init"
70
+ exit Gitjira::Setup.init(options[:force])
71
+ when "config"
72
+ puts "JIRA Host...........: #{Gitjira::InformationFetching.host}"
73
+ puts "JIRA Project Key....: #{Gitjira::InformationFetching.project_key}"
74
+ puts "JIRA Username.......: #{Gitjira::InformationFetching.username}"
75
+ exit 0
76
+ when "list"
77
+ list
62
78
  when "describe"
63
79
  begin
64
- Gitjira::InformationFetching.describe(options[:issue])
80
+ exit Gitjira::InformationFetching.describe(options[:issue])
65
81
  rescue => e
66
82
  STDERR.puts "[ERROR] Not able to fetch issue information from JIRA, through exception: #{e}"
83
+ exit 2
67
84
  end
68
85
  else
69
- STDOUT.puts opt_parser
86
+ list
70
87
  end
88
+
data/bin/gj ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+ #####
3
+ # Copyright (c) 2013 by Sigimera Ltd.
4
+ # All rights reserved.
5
+ #####
6
+ require 'rubygems'
7
+ require 'optparse'
8
+ require 'json'
9
+
10
+ begin
11
+ require "gitjira"
12
+ rescue LoadError => e
13
+ STDERR.puts "Install the missing library:\n\t \e[0;36m$\e[m \e[0;32mgem install gitjira\e[m"
14
+ exit
15
+ end
16
+
17
+ options = { :force => false, :issue => nil }
18
+
19
+ opt_parser = OptionParser.new do |opt|
20
+ opt.banner = "Usage: git-jira [COMMANDS] [OPTIONS]"
21
+ opt.separator "Alternative: gj [COMMANDS] [OPTIONS]"
22
+ opt.separator ""
23
+ opt.separator "Commands"
24
+ opt.separator " init [-f | --force] setup the current repository to be able to connect to a JIRA project"
25
+ opt.separator " config output the configuration fields as specified under .git/config"
26
+ opt.separator " list returns a list of branches with related issue information"
27
+ opt.separator " describe [-i | --issue] verbose issue information related to the current branch or specified issue"
28
+ opt.separator ""
29
+ opt.separator "Options"
30
+
31
+ opt.on("-h", "--help", "help") do
32
+ STDOUT.puts opt_parser
33
+ exit 0
34
+ end
35
+
36
+ opt.on("-v", "--version", "print out current Version number") do
37
+ STDOUT.puts "gitjira-#{Gitjira::VERSION}"
38
+ exit 0
39
+ end
40
+
41
+ opt.on("-f", "--force", "force overwrite of .git/config [gitjira] block") do
42
+ options[:force] = true
43
+ end
44
+
45
+ opt.on("-i", "--issue [ISSUE]", "specify an issue number, e.g. PROJ-123 or 123") do |i|
46
+ options[:issue] = i if i
47
+ end
48
+
49
+ opt.separator ""
50
+ opt.separator "Copyright (C) 2013 Sigimera Ltd."
51
+ end
52
+
53
+ opt_parser.parse!
54
+
55
+ def list
56
+ unless Gitjira::Setup.setup?
57
+ STDERR.puts "[SETUP] This repository is not setup, please execute: `git-jira init`"
58
+ exit 1
59
+ end
60
+ begin
61
+ exit Gitjira::InformationFetching.branches
62
+ rescue => e
63
+ STDERR.puts "[ERROR] Not able to fetch issue information from JIRA, through exception: #{e}"
64
+ exit 2
65
+ end
66
+ end
67
+
68
+ case ARGV[0]
69
+ when "init"
70
+ exit Gitjira::Setup.init(options[:force])
71
+ when "config"
72
+ puts "JIRA Host...........: #{Gitjira::InformationFetching.host}"
73
+ puts "JIRA Project Key....: #{Gitjira::InformationFetching.project_key}"
74
+ puts "JIRA Username.......: #{Gitjira::InformationFetching.username}"
75
+ exit 0
76
+ when "list"
77
+ list
78
+ when "describe"
79
+ begin
80
+ exit Gitjira::InformationFetching.describe(options[:issue])
81
+ rescue => e
82
+ STDERR.puts "[ERROR] Not able to fetch issue information from JIRA, through exception: #{e}"
83
+ exit 2
84
+ end
85
+ else
86
+ list
87
+ end
88
+
@@ -30,11 +30,16 @@ class Gitjira::InformationFetching
30
30
  end
31
31
  end
32
32
 
33
- return nil
33
+ if issues_printed.size == 0
34
+ STDERR.puts "[Warning] No branch found that is related to an issue. You can try `git-jira describe -i ###`"
35
+ return 1
36
+ else
37
+ return 0
38
+ end
34
39
  end
35
40
 
36
41
  def self.describe(issue = nil)
37
- issue = "#{self.project_key}-#{issue}" if issue and not issue.start_with?(self.project_key)
42
+ issue = "#{self.project_key}-#{issue}" if issue and not issue.to_s.start_with?(self.project_key)
38
43
  issue = self.extract_issue unless issue
39
44
 
40
45
  if issue
@@ -66,11 +71,15 @@ class Gitjira::InformationFetching
66
71
  puts ""
67
72
  puts "#{fields['description']}"
68
73
  end
74
+
75
+ return 0
69
76
  else
70
77
  puts "[Error] Not able to extract issue information of '#{issue}'"
78
+ return 2
71
79
  end
72
80
  else
73
- puts "[Warning] You are currently in no branch that is related to an issue."
81
+ puts "[Warning] You are currently in no issue related branch. You can try `git-jira describe -i ###`"
82
+ return 1
74
83
  end
75
84
  end
76
85
 
@@ -117,6 +126,14 @@ class Gitjira::InformationFetching
117
126
  `git config --local --get gitjira.host`.chomp
118
127
  end
119
128
 
129
+ def self.username
130
+ encoded = self.credentials
131
+ credentials = Base64.strict_decode64(encoded)
132
+ username = credentials.split(":").first
133
+ encoded = credentials = nil
134
+ username
135
+ end
136
+
120
137
  private
121
138
  def self.fetch_issue_json(issue_name)
122
139
  jira_url = "#{self.host}rest/api/2/issue/"
@@ -5,12 +5,9 @@ class Gitjira::Setup
5
5
  if self.setup? and not force
6
6
  STDERR.puts "Repository is configured. Overwrite with:"
7
7
  STDERR.puts "\t$ git-jira init -f # or git-jira init --force."
8
- return
8
+ return 1
9
9
  end
10
- host = nil
11
- username = nil
12
- password = nil
13
- projectkey = nil
10
+ host = username = password = projectkey= nil
14
11
 
15
12
  host = ask("JIRA host (e.g. https://jira.example.org): ")
16
13
  host = "#{host}/" if not host.empty? and not host.end_with?("/")
@@ -26,8 +23,10 @@ class Gitjira::Setup
26
23
  `git config --local gitjira.host #{host}`
27
24
  `git config --local gitjira.credentials #{base64.to_s}`
28
25
  `git config --local gitjira.projectkey #{projectkey}`
26
+ return 0
29
27
  else
30
28
  STDERR.puts "[ERROR] Please fill out all needed fields."
29
+ return 1
31
30
  end
32
31
 
33
32
  end
@@ -1,3 +1,3 @@
1
1
  module Gitjira
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.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.2.0
4
+ version: 0.3.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-22 00:00:00.000000000 Z
11
+ date: 2013-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -72,6 +72,7 @@ email:
72
72
  - alex.oberhauser@sigimera.org
73
73
  executables:
74
74
  - git-jira
75
+ - gj
75
76
  extensions: []
76
77
  extra_rdoc_files: []
77
78
  files:
@@ -82,6 +83,7 @@ files:
82
83
  - README.md
83
84
  - Rakefile
84
85
  - bin/git-jira
86
+ - bin/gj
85
87
  - gitjira.gemspec
86
88
  - lib/gitjira.rb
87
89
  - lib/gitjira/information_fetching.rb