git_scf 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,20 +1,22 @@
1
- class EnvConfig
1
+ module GitScf
2
+ class EnvConfig
2
3
 
3
- def initialize(repo)
4
- @repo = repo
5
- end
4
+ def initialize(repo)
5
+ @repo = repo
6
+ end
6
7
 
7
- def get(key)
8
- ENV[key] || @repo.config["gitscf.#{git_key(key)}"]
9
- end
8
+ def get(key)
9
+ ENV[key] || @repo.config["gitscf.#{git_key(key)}"]
10
+ end
10
11
 
11
- def repo
12
- @repo
13
- end
12
+ def repo
13
+ @repo
14
+ end
14
15
 
15
- private
16
+ private
16
17
 
17
- def git_key(key)
18
- key.downcase.gsub('_','')
18
+ def git_key(key)
19
+ key.downcase.gsub('_','')
20
+ end
19
21
  end
20
22
  end
data/lib/git_scf/jira.rb CHANGED
@@ -1,23 +1,25 @@
1
- class Jira
2
- require 'jira'
3
-
4
- def initialize(config)
5
- @config = config
6
- options = { username: config.get('JIRA_USERNAME'),
7
- password: config.get('JIRA_PASSWORD'),
8
- use_ssl: true,
9
- site: 'https://seeclickfix.atlassian.net',
10
- context_path: '/',
11
- rest_base_path: 'rest/api/2',
12
- auth_type: :basic }
13
- @jira = JIRA::Client.new(options)
14
- end
1
+ module GitScf
2
+ class Jira
3
+ require 'jira'
4
+
5
+ def initialize(config)
6
+ @config = config
7
+ options = { username: config.get('JIRA_USERNAME'),
8
+ password: config.get('JIRA_PASSWORD'),
9
+ use_ssl: true,
10
+ site: 'https://seeclickfix.atlassian.net',
11
+ context_path: '/',
12
+ rest_base_path: 'rest/api/2',
13
+ auth_type: :basic }
14
+ @jira = JIRA::Client.new(options)
15
+ end
15
16
 
16
- def config
17
- @config
18
- end
17
+ def config
18
+ @config
19
+ end
19
20
 
20
- def ticket(id)
21
- @jira.Issue.find(id)
21
+ def ticket(id)
22
+ @jira.Issue.find(id)
23
+ end
22
24
  end
23
25
  end
@@ -1,19 +1,21 @@
1
- class Logger
1
+ module GitScf
2
+ class Logger
2
3
 
3
- LOG_PATH = '.gitscf'
4
+ LOG_PATH = '.gitscf'
4
5
 
5
- def initialize(ticket)
6
- `mkdir -p #{LOG_PATH}`
7
- @filename = "#{ticket.id}"
8
- end
6
+ def initialize(ticket)
7
+ `mkdir -p #{LOG_PATH}`
8
+ @filename = "#{ticket.id}"
9
+ end
9
10
 
10
- def add(string)
11
- `echo '#{string} #{`date`}' >> #{log_file}`
12
- end
11
+ def add(string)
12
+ `echo '#{string} #{`date`}' >> #{log_file}`
13
+ end
13
14
 
14
- private
15
+ private
15
16
 
16
- def log_file
17
- "#{LOG_PATH}/#{@filename}"
17
+ def log_file
18
+ "#{LOG_PATH}/#{@filename}"
19
+ end
18
20
  end
19
21
  end
@@ -1,16 +1,18 @@
1
- class Finish
2
- def initialize(ticket, logger)
3
- @ticket = ticket
4
- @logger = logger
5
- end
1
+ module GitScf
2
+ class Finish
3
+ def initialize(ticket, logger)
4
+ @ticket = ticket
5
+ @logger = logger
6
+ end
6
7
 
7
- def execute
8
- @logger.add("Closing out #{@ticket.branch_name}")
9
- `git add .`
10
- `git commit -am "#{@ticket.id} #done"`
11
- `git push`
12
- `git flow feature finish #{@ticket.branch_name}`
13
- `git push`
14
- `git push origin :refs/heads/feature/#{@ticket.branch_name}`
8
+ def execute
9
+ @logger.add("Closing out #{@ticket.branch_name}")
10
+ `git add .`
11
+ `git commit -am "#{@ticket.id} #done"`
12
+ `git push`
13
+ `git flow feature finish #{@ticket.branch_name}`
14
+ `git push`
15
+ `git push origin :refs/heads/feature/#{@ticket.branch_name}`
16
+ end
15
17
  end
16
18
  end
@@ -1,16 +1,18 @@
1
- class Review
1
+ module GitScf
2
+ class Review
2
3
 
3
- def initialize(ticket, logger)
4
- @ticket = ticket
5
- @logger = logger
6
- end
4
+ def initialize(ticket, logger)
5
+ @ticket = ticket
6
+ @logger = logger
7
+ end
7
8
 
8
- def execute
9
- @logger.add("Reviewing #{@ticket.branch_name}")
10
- `git add .`
11
- `git commit -am "#{@ticket.id} #review"`
12
- `git push`
13
- `hub pull-request "Addresses #{@ticket.id} #{@ticket.summary} please review." | pbcopy`
14
- puts "The code-review URL is in your clipboard."
9
+ def execute
10
+ @logger.add("Reviewing #{@ticket.branch_name}")
11
+ `git add .`
12
+ `git commit -am "#{@ticket.id} #review"`
13
+ `git push`
14
+ `hub pull-request "Addresses #{@ticket.id} #{@ticket.summary} please review." | pbcopy`
15
+ puts "The code-review URL is in your clipboard."
16
+ end
15
17
  end
16
18
  end
@@ -1,21 +1,23 @@
1
- class Show
1
+ module GitScf
2
+ class Show
2
3
 
3
- def initialize(ticket, verbose)
4
- @ticket = ticket
5
- @verbose = verbose
6
- end
4
+ def initialize(ticket, verbose)
5
+ @ticket = ticket
6
+ @verbose = verbose
7
+ end
7
8
 
8
- def execute
9
- jira_ticket = @ticket.jira_ticket
10
- puts "Summary: #{jira_ticket.summary}"
11
- puts "Status: #{jira_ticket.status.name}"
12
- puts "Created at: #{jira_ticket.created}"
13
- if @verbose
14
- puts "Description: #{jira_ticket.description}"
15
- jira_ticket.comments.each do |comment|
16
- puts ""
17
- puts "#{comment.author['name']} wrote: #{comment.body}"
18
- end
19
- end
20
- end
21
- end
9
+ def execute
10
+ jira_ticket = @ticket.jira_ticket
11
+ puts "Summary: #{jira_ticket.summary}"
12
+ puts "Status: #{jira_ticket.status.name}"
13
+ puts "Created at: #{jira_ticket.created}"
14
+ if @verbose
15
+ puts "Description: #{jira_ticket.description}"
16
+ jira_ticket.comments.each do |comment|
17
+ puts ""
18
+ puts "#{comment.author['name']} wrote: #{comment.body}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,17 +1,18 @@
1
- class Start
1
+ module GitScf
2
+ class Start
3
+ def initialize(ticket, logger)
4
+ @ticket = ticket
5
+ @logger = logger
6
+ end
2
7
 
3
- def initialize(ticket, logger)
4
- @ticket = ticket
5
- @logger = logger
6
- end
7
-
8
- def execute
9
- `git checkout develop`
10
- `git pull`
11
- `git flow feature start #{@ticket.branch_name}`
12
- @logger.add("Started #{@ticket.branch_name}")
13
- `git add .`
14
- `git commit -am "#{@ticket.id} #in-progress"`
15
- `git flow feature publish #{@ticket.branch_name}`
8
+ def execute
9
+ `git checkout develop`
10
+ `git pull`
11
+ `git flow feature start #{@ticket.branch_name}`
12
+ @logger.add("Started #{@ticket.branch_name}")
13
+ `git add .`
14
+ `git commit -am "#{@ticket.id} #in-progress"`
15
+ `git flow feature publish #{@ticket.branch_name}`
16
+ end
16
17
  end
17
18
  end
@@ -1,53 +1,55 @@
1
- class Ticket
1
+ module GitScf
2
+ class Ticket
2
3
 
3
- def initialize(jira)
4
- @repo = jira.config.repo
5
- @jira = jira
6
- end
4
+ def initialize(jira)
5
+ @repo = jira.config.repo
6
+ @jira = jira
7
+ end
7
8
 
8
- def id
9
- @id ||= id_by_argument_or_branch
10
- end
9
+ def id
10
+ @id ||= id_by_argument_or_branch
11
+ end
11
12
 
12
- def branch_name
13
- "#{id}-#{parameterize(summary)[0..50]}"
14
- end
13
+ def branch_name
14
+ "#{id}-#{parameterize(summary)[0..50]}"
15
+ end
15
16
 
16
- def jira_ticket
17
- @jira && @jira.ticket(id)
18
- end
17
+ def jira_ticket
18
+ @jira && @jira.ticket(id)
19
+ end
19
20
 
20
- def summary
21
- jira_ticket && jira_ticket.summary
22
- end
21
+ def summary
22
+ jira_ticket && jira_ticket.summary
23
+ end
23
24
 
24
- private
25
+ private
25
26
 
26
- def id_by_argument_or_branch
27
- ARGV.size == 2 ? ARGV.pop : id_from_branch
28
- end
27
+ def id_by_argument_or_branch
28
+ ARGV.size == 2 ? ARGV.pop : id_from_branch
29
+ end
29
30
 
30
- def name_from_branch
31
- @repo.head.name.split('/')[-1][/^.*-.*$/]
32
- end
31
+ def name_from_branch
32
+ @repo.head.name.split('/')[-1][/^.*-.*$/]
33
+ end
33
34
 
34
- def id_from_branch
35
- parts = name_from_branch.split('-')
36
- "#{parts[0]}-#{parts[1]}"
37
- end
35
+ def id_from_branch
36
+ parts = name_from_branch.split('-')
37
+ "#{parts[0]}-#{parts[1]}"
38
+ end
38
39
 
39
- # Stolen from ActiveSupport
40
- def parameterize(string, sep = '-')
41
- # Turn unwanted chars into the separator
42
- string.gsub!(/[^a-zA-Z0-9\-_]+/, sep)
43
- unless sep.nil? || sep.empty?
44
- re_sep = Regexp.escape(sep)
45
- # No more than one of the separator in a row.
46
- string.gsub!(/#{re_sep}{2,}/, sep)
47
- # Remove leading/trailing separator.
48
- string.gsub!(/^#{re_sep}|#{re_sep}$/, '')
49
- end
50
- string.downcase
51
- end
40
+ # Stolen from ActiveSupport
41
+ def parameterize(string, sep = '-')
42
+ # Turn unwanted chars into the separator
43
+ string.gsub!(/[^a-zA-Z0-9\-_]+/, sep)
44
+ unless sep.nil? || sep.empty?
45
+ re_sep = Regexp.escape(sep)
46
+ # No more than one of the separator in a row.
47
+ string.gsub!(/#{re_sep}{2,}/, sep)
48
+ # Remove leading/trailing separator.
49
+ string.gsub!(/^#{re_sep}|#{re_sep}$/, '')
50
+ end
51
+ string.downcase
52
+ end
52
53
 
53
- end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module GitScf
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: