git_scf 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1 +1,47 @@
1
- TODO
1
+ ## GitScf
2
+ Git tools to simplify the workflow at SeeClickFix
3
+
4
+ ### Installation
5
+
6
+ $ gem install git_scf
7
+
8
+ Configure jira credentials. Either set them in your environment:
9
+
10
+ $ export JIRA_USERNAME="your-jira-username"
11
+ $ export JIRA_PASSWORD="your-jira-password"
12
+
13
+ or in your git config:
14
+
15
+ $ git config --global gitscf.jirausername "your-jira-username"
16
+ $ git config --global gitscf.jirapassword "your-jira-password"
17
+
18
+ ### Usage
19
+
20
+ Usage: git scf (start|show|review|finish) [issue_number]
21
+ -v, --verbose Output more information
22
+ -h, --help Display this screen
23
+
24
+ START - Start a feature branch based on the ticket ID.
25
+
26
+ $ git scf start SCF-100
27
+
28
+ SHOW - Show jira information about tickets.
29
+
30
+ $ git scf show # shows info on the current branch
31
+ $ git scf show -v # include description and comments
32
+ $ git scf show SCF-500 # specify a different ticket ID
33
+
34
+ REVIEW - Create a pull request in github on the current branch.
35
+
36
+ $ git scf review
37
+
38
+ FINISH - Close out the current feature branch and code review.
39
+
40
+ $ git scf finish
41
+
42
+ ### Todo
43
+ Contributions are appreciated!
44
+
45
+ - Tests
46
+ - Better error handling
47
+ - Less backtick system calls
@@ -5,6 +5,16 @@ class EnvConfig
5
5
  end
6
6
 
7
7
  def get(key)
8
- ENV[key] || repo.config["scfgit.#{key.downcase}"]
8
+ ENV[key] || @repo.config["gitscf.#{git_key(key)}"]
9
+ end
10
+
11
+ def repo
12
+ @repo
13
+ end
14
+
15
+ private
16
+
17
+ def git_key(key)
18
+ key.downcase.gsub('_','')
9
19
  end
10
20
  end
data/lib/git_scf/jira.rb CHANGED
@@ -2,6 +2,7 @@ class Jira
2
2
  require 'jira'
3
3
 
4
4
  def initialize(config)
5
+ @config = config
5
6
  options = { username: config.get('JIRA_USERNAME'),
6
7
  password: config.get('JIRA_PASSWORD'),
7
8
  use_ssl: true,
@@ -12,6 +13,10 @@ class Jira
12
13
  @jira = JIRA::Client.new(options)
13
14
  end
14
15
 
16
+ def config
17
+ @config
18
+ end
19
+
15
20
  def ticket(id)
16
21
  @jira.Issue.find(id)
17
22
  end
@@ -1,10 +1,10 @@
1
1
  class Logger
2
2
 
3
- LOG_PATH = 'script/scfgit'
4
- LOG_FILE = 'log'
3
+ LOG_PATH = '.gitscf'
5
4
 
6
- def initialize
5
+ def initialize(ticket)
7
6
  `mkdir -p #{LOG_PATH}`
7
+ @filename = "#{ticket.id}"
8
8
  end
9
9
 
10
10
  def add(string)
@@ -14,6 +14,6 @@ class Logger
14
14
  private
15
15
 
16
16
  def log_file
17
- "#{LOG_PATH}/#{LOG_FILE}"
17
+ "#{LOG_PATH}/#{@filename}"
18
18
  end
19
19
  end
@@ -10,7 +10,7 @@ class Review
10
10
  `git add .`
11
11
  `git commit -am "#{@ticket.id} #review"`
12
12
  `git push`
13
- `hub pull-request "Addresses #{@ticket.id} please review." | pbcopy`
13
+ `hub pull-request "Addresses #{@ticket.id} #{@ticket.summary} please review." | pbcopy`
14
14
  puts "The code-review URL is in your clipboard."
15
15
  end
16
16
  end
@@ -1,7 +1,7 @@
1
1
  class Ticket
2
2
 
3
- def initialize(repo, jira)
4
- @repo = repo
3
+ def initialize(jira)
4
+ @repo = jira.config.repo
5
5
  @jira = jira
6
6
  end
7
7
 
@@ -10,19 +10,19 @@ class Ticket
10
10
  end
11
11
 
12
12
  def branch_name
13
- "#{id}-#{parameterize(summary)}"
13
+ "#{id}-#{parameterize(summary)[0..50]}"
14
14
  end
15
15
 
16
16
  def jira_ticket
17
17
  @jira && @jira.ticket(id)
18
18
  end
19
19
 
20
- private
21
-
22
20
  def summary
23
21
  jira_ticket && jira_ticket.summary
24
22
  end
25
23
 
24
+ private
25
+
26
26
  def id_by_argument_or_branch
27
27
  ARGV.size == 2 ? ARGV.pop : id_from_branch
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module GitScf
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/git_scf.rb CHANGED
@@ -45,13 +45,14 @@ module GitScf
45
45
  rescue
46
46
  puts "ERROR: Invalid git directory"
47
47
  puts opts
48
- exit
48
+ exit
49
49
  end
50
50
 
51
- jira = Jira.new(EnvConfig.new(repo))
52
- ticket = Ticket.new(repo, jira)
53
- logger = Logger.new
54
-
51
+ config = EnvConfig.new(repo)
52
+ jira = Jira.new(config)
53
+ ticket = Ticket.new(jira)
54
+ logger = Logger.new(ticket)
55
+
55
56
  case ARGV.first
56
57
  when 'start'
57
58
  Start.new(ticket, logger)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_scf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -64,17 +64,17 @@ dependencies:
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ! '>='
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: 0.17.0.b7
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ! '>='
75
+ - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '0'
77
+ version: 0.17.0.b7
78
78
  description: ! " Provides git tools that match the SCF workflow. \n"
79
79
  email: jeff@seeclickfix.com
80
80
  executables: