Skip to content

Commit 89ffe55

Browse files
committed
commit for current worktime
1 parent c1fa4d6 commit 89ffe55

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

lib/redmine_cli/tasks/commit.rb

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Commit < Base
1414
class_option :assigned_to_me, :type => :boolean, :aliases => "-I", :desc => "Only show issues that are assigned to me."
1515

1616
['fixes', 'closes', 'refs'].each do |method|
17-
desc "#{method} <search> [-a] [-m <msg>] [-A | -C] [-I]", "Search for issue and commit with #{method}."
17+
desc "#{method} [<search>] [-a] [-m <msg>] [-A | -C] [-I]", "Search for issue and commit with #{method}."
1818
define_method method do |*args|
1919
commit(args.first, options.merge(:prefix => method))
2020
end
@@ -23,13 +23,28 @@ class Commit < Base
2323
private
2424

2525
def commit(term, options)
26-
matching = fetch_issues(term, options)
27-
28-
if issue = RedmineCLI.ui.choose_issue(matching)
29-
exec %`git commit -m "#{options[:prefix]} ##{issue['id']}: #{options[:msg]}" #{options[:msg] ? '' : '-e'} #{options[:all] ? '-a' : ''}`
26+
if term.nil?
27+
worktime = Worktime.current
28+
29+
if worktime && worktime.issue?
30+
issue = {
31+
'id' => worktime.issue_id
32+
}
33+
else
34+
puts "Cannot determine issue from worktime. Not signed in for any issue."
35+
return
36+
end
3037
else
31-
puts "Bye."
38+
matching = fetch_issues(term, options)
39+
issue = RedmineCLI.ui.choose_issue(matching)
40+
41+
unless issue
42+
puts "Bye."
43+
return
44+
end
3245
end
46+
47+
exec %`git commit -m "#{options[:prefix]} ##{issue['id']}: #{options[:msg]}" #{options[:msg] ? '' : '-e'} #{options[:all] ? '-a' : ''}`
3348
end
3449

3550
def fetch_issues(term, options)
@@ -42,7 +57,6 @@ def fetch_issues(term, options)
4257

4358
query.all
4459
end
45-
4660
end
4761
end
4862
end

lib/redmine_cli/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RedmineCLI
2-
VERSION = '0.2.1'
2+
VERSION = '0.3.0'
33
end

0 commit comments

Comments
 (0)