@@ -14,7 +14,7 @@ class Commit < Base
14
14
class_option :assigned_to_me , :type => :boolean , :aliases => "-I" , :desc => "Only show issues that are assigned to me."
15
15
16
16
[ '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 } ."
18
18
define_method method do |*args |
19
19
commit ( args . first , options . merge ( :prefix => method ) )
20
20
end
@@ -23,13 +23,28 @@ class Commit < Base
23
23
private
24
24
25
25
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
30
37
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
32
45
end
46
+
47
+ exec %`git commit -m "#{ options [ :prefix ] } ##{ issue [ 'id' ] } : #{ options [ :msg ] } " #{ options [ :msg ] ? '' : '-e' } #{ options [ :all ] ? '-a' : '' } `
33
48
end
34
49
35
50
def fetch_issues ( term , options )
@@ -42,7 +57,6 @@ def fetch_issues(term, options)
42
57
43
58
query . all
44
59
end
45
-
46
60
end
47
61
end
48
62
end
0 commit comments