gitjira 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0147528c9d34712e1c91f84925d60eb10b9a00d4
4
+ data.tar.gz: 97221c58ff272776c58300aeb98be2d3b04938bd
5
+ SHA512:
6
+ metadata.gz: baa75186006988fe01740403778b8b46c71ca066cb23eef9dca279860af435295cac372305100aeb52c51afd83f995b98ced03aa0c0d47ecf5323cae2266caec
7
+ data.tar.gz: c8540bd0696b36a0f749fba1c37c6e3b8a242c4954621d9099e5eaeb23aea460fe31c7f415ce73453c756e104889729c1a23b5e939f59f1f5a38d3fb0983f898
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sigtools.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitjira (0.0.1)
5
+ highline
6
+ parseconfig
7
+ rest-client (~> 1.6)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ highline (1.6.19)
13
+ mime-types (1.23)
14
+ parseconfig (1.0.2)
15
+ rake (10.0.4)
16
+ rest-client (1.6.7)
17
+ mime-types (>= 1.16)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ bundler (~> 1.3)
24
+ gitjira!
25
+ rake
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # gitjira
2
+
3
+ Git JIRA is an extension that combines feature or all other type of branches
4
+ with JIRA issues. It shows the current status and the summary of the issue.
5
+
6
+ In order to be able to combine branches the branch name must include the following
7
+ string _PROJECTKEY-###_
8
+
9
+ Examples if the project key is _PROJ_ and the issue number _123_
10
+
11
+ features/PROJ-123_some_description
12
+ someprefix/PROJ-123_some_description
13
+ PROJ-123
14
+ PROJ-123_description
15
+
16
+ ### Setup:
17
+
18
+ $ git jira init
19
+ JIRA host (e.g. https://jira.example.org): http://www.example.org/jira
20
+ Your JIRA username : johnny
21
+ Your JIRA password : ************
22
+ Related JIRA project key (e.g. PROJ) : PROJ
23
+
24
+
25
+ ### Example Scenario - Feature Branches:
26
+
27
+ $ git jira list
28
+ Open 0% done PROJ-123 - Implement some new feature
29
+ Resolved 100% done PROJ-20 - And yet another feature
30
+ Resolved 42% done PROJ-16 - Add /features page
31
+
32
+
33
+ ## Installation
34
+
35
+ Install via rubygems.org:
36
+
37
+ $ gem install gitjira
38
+
39
+ ## Usage
40
+
41
+ # See what commands are available.
42
+ $ git-jira --help # or git jira -h
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
51
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/git-jira ADDED
@@ -0,0 +1,55 @@
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 = {}
18
+
19
+ opt_parser = OptionParser.new do |opt|
20
+ opt.banner = "Usage: git-jira [COMMANDS] [OPTIONS]"
21
+ opt.separator ""
22
+ opt.separator "Commands"
23
+ opt.separator " init: 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 ""
26
+
27
+ opt.on("-h", "--help", "help") do
28
+ STDOUT.puts opt_parser
29
+ exit
30
+ end
31
+
32
+ opt.on("-v", "--version", "print out current Version number") do
33
+ STDOUT.puts "sigtools-#{Gitjira::VERSION}"
34
+ exit
35
+ end
36
+ end
37
+
38
+ opt_parser.parse!
39
+
40
+ case ARGV[0]
41
+ when "init"
42
+ Gitjira::Setup.init
43
+ when "list"
44
+ unless Gitjira::Setup.setup?
45
+ STDERR.puts "[SETUP] This repository is not setup correcly, please execute: `git-jira init`"
46
+ exit
47
+ end
48
+ begin
49
+ Gitjira::InformationFetching.branches
50
+ rescue => e
51
+ STDERR.puts "[ERROR] Not able to fetch feature branch information from JIRA, through exception: #{e}"
52
+ end
53
+ else
54
+ STDOUT.puts opt_parser
55
+ end
data/gitjira.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitjira/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gitjira"
8
+ spec.version = Gitjira::VERSION
9
+ spec.authors = ["Alex Oberhauser"]
10
+ spec.email = ["alex.oberhauser@sigimera.org"]
11
+ spec.description = %q{Git JIRA is an extension that combines feature or all other type of branches with JIRA issues. It shows the current status and the summary of the issue.}
12
+ spec.summary = %q{A git extension that combines feature branches with JIRA issues.}
13
+ spec.homepage = "https://github.com/Sigimera/gitjira"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rest-client", "~> 1.6"
22
+ spec.add_dependency "highline"
23
+ spec.add_dependency "parseconfig"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,51 @@
1
+ class Gitjira::InformationFetching
2
+
3
+ def self.branches
4
+ jira_url = "#{Gitjira::InformationFetching.host}rest/api/2/issue/"
5
+ credentials = Gitjira::InformationFetching.credentials
6
+ project_key = Gitjira::InformationFetching.project_key
7
+ branches = `git branch -a`.split("\n")
8
+ issues = Array.new
9
+ issues_printed = Array.new
10
+
11
+ branches.each do |current_branch|
12
+ branch = current_branch[/#{project_key}-\d+/]
13
+ if branch
14
+ unless issues_printed.include?(branch)
15
+ issues_printed << branch
16
+ fetch = true
17
+ end
18
+ end
19
+
20
+ if fetch
21
+ response = RestClient::Resource.new("#{jira_url}#{branch}", {
22
+ :headers => { "Authorization" => "Basic #{credentials}" }
23
+ }).get
24
+ json = JSON.parse(response)
25
+ if json['fields']['progress']['percent']
26
+ puts sprintf "%-12s %3.0f%s\t%-14s - %s", json['fields']['status']['name'], json['fields']['progress']['percent'], "% done", branch, json['fields']['summary']
27
+ else
28
+ puts sprintf "%-12s\t\t%-14s - %s", json['fields']['status']['name'], branch, json['fields']['summary']
29
+ end
30
+
31
+ fetch = false
32
+ end
33
+ end
34
+
35
+ return nil
36
+ end
37
+
38
+ def self.project_key
39
+ `git config --local --get gitjira.projectkey`.chomp
40
+ end
41
+
42
+ def self.credentials
43
+ `git config --local --get gitjira.credentials`.chomp
44
+ end
45
+
46
+ def self.host
47
+ `git config --local --get gitjira.host`.chomp
48
+ end
49
+
50
+ end
51
+
@@ -0,0 +1,33 @@
1
+ require "base64"
2
+
3
+ class Gitjira::Setup
4
+ def self.init
5
+ host = nil
6
+ username = nil
7
+ password = nil
8
+ projectkey = nil
9
+
10
+ host = ask("JIRA host (e.g. https://jira.example.org): ")
11
+ host = "#{host}/" if not host.empty? and not host.end_with?("/")
12
+
13
+ username = ask("Your JIRA username : ")
14
+ password = ask("Your JIRA password : "){ |q| q.echo = "*" }
15
+ base64 = Base64.strict_encode64("#{username}:#{password}")
16
+ username = password = nil
17
+
18
+ projectkey = ask("Related JIRA project key (e.g. PROJ) : ")
19
+
20
+ if not host.empty? and not projectkey.empty?
21
+ `git config --local gitjira.host #{host}`
22
+ `git config --local gitjira.credentials #{base64.to_s}`
23
+ `git config --local gitjira.projectkey #{projectkey}`
24
+ else
25
+ STDERR.puts "[ERROR] Please fill out all needed fields."
26
+ end
27
+
28
+ end
29
+
30
+ def self.setup?
31
+ `git config --local --get gitjira.host`.empty? ? false : true
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Gitjira
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gitjira.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "json"
2
+ require "rest-client"
3
+ require "highline/import"
4
+
5
+ require "gitjira/version"
6
+
7
+ # Module that extends git with capabilites to fetch issue information from
8
+ # Atlassian JIRA
9
+ module Gitjira
10
+
11
+ end
12
+
13
+ require "gitjira/setup"
14
+ require "gitjira/information_fetching"
15
+
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitjira
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Oberhauser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: highline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: parseconfig
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Git JIRA is an extension that combines feature or all other type of branches
84
+ with JIRA issues. It shows the current status and the summary of the issue.
85
+ email:
86
+ - alex.oberhauser@sigimera.org
87
+ executables:
88
+ - git-jira
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - .gitignore
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/git-jira
99
+ - gitjira.gemspec
100
+ - lib/gitjira.rb
101
+ - lib/gitjira/information_fetching.rb
102
+ - lib/gitjira/setup.rb
103
+ - lib/gitjira/version.rb
104
+ homepage: https://github.com/Sigimera/gitjira
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.0.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A git extension that combines feature branches with JIRA issues.
128
+ test_files: []
129
+ has_rdoc: