bugzyrb 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +5 -1
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/bugzyrb.gemspec +6 -6
- data/lib/{common → bugzyrb/common}/cmdapp.rb +40 -5
- data/lib/{common → bugzyrb/common}/colorconstants.rb +0 -0
- data/lib/{common → bugzyrb/common}/db.rb +6 -30
- data/lib/{common → bugzyrb/common}/sed.rb +0 -0
- data/lib/bugzyrb.rb +71 -56
- metadata +7 -7
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
-
= bugzyrb 0.2.
|
1
|
+
= bugzyrb 0.2.1, 2010-07-09
|
2
|
+
* added status which was missing
|
3
|
+
* delete can take multiple issues
|
4
|
+
|
5
|
+
= bugzyrb 0.2.0, 2010-07-08
|
2
6
|
* added readline support and history for fields being entered
|
3
7
|
* optional project, component, version
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= bugzyrb
|
2
2
|
|
3
|
-
A command-line bug tracking system using sqlite3 as a store.
|
3
|
+
A command-line bug/issue/feature tracking system using sqlite3 as a store.
|
4
4
|
This is a port of bugzy.sh (bash-shell based tracker that uses tab delimited files).
|
5
5
|
|
6
6
|
This is not an extensive, full-fledged bug or issue tracker such a bugzilla. Its a simple tracker that maintains one sqlite file per directory. Thus, you could create one for each project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/bugzyrb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bugzyrb}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rahul Kumar"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-09}
|
13
13
|
s.default_executable = %q{bugzyrb}
|
14
14
|
s.description = %q{basic, easy-to-use command-line issue-tracker using sqlite for ruby 1.9}
|
15
15
|
s.email = %q{sentinel1879@gmail.com}
|
@@ -30,10 +30,10 @@ Gem::Specification.new do |s|
|
|
30
30
|
"bugzy.cfg",
|
31
31
|
"bugzyrb.gemspec",
|
32
32
|
"lib/bugzyrb.rb",
|
33
|
-
"lib/common/cmdapp.rb",
|
34
|
-
"lib/common/colorconstants.rb",
|
35
|
-
"lib/common/db.rb",
|
36
|
-
"lib/common/sed.rb"
|
33
|
+
"lib/bugzyrb/common/cmdapp.rb",
|
34
|
+
"lib/bugzyrb/common/colorconstants.rb",
|
35
|
+
"lib/bugzyrb/common/db.rb",
|
36
|
+
"lib/bugzyrb/common/sed.rb"
|
37
37
|
]
|
38
38
|
s.homepage = %q{http://github.com/rkumar/bugzyrb}
|
39
39
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -8,7 +8,8 @@
|
|
8
8
|
* License: Ruby License
|
9
9
|
|
10
10
|
=end
|
11
|
-
|
11
|
+
# sed required by serial number setter only change_file
|
12
|
+
require 'bugzyrb/common/sed'
|
12
13
|
|
13
14
|
ERRCODE = 1
|
14
15
|
|
@@ -133,6 +134,7 @@ module Cmdapp
|
|
133
134
|
_get_serial_number
|
134
135
|
end
|
135
136
|
_backup filename
|
137
|
+
# from Sed
|
136
138
|
change_row filename, pattern, "#{appname}:#{number}"
|
137
139
|
end
|
138
140
|
|
@@ -173,8 +175,7 @@ module Cmdapp
|
|
173
175
|
$valid_array = false
|
174
176
|
@data = []
|
175
177
|
File.open(@app_file_path).each do |line|
|
176
|
-
|
177
|
-
row = line.chomp.split "\t"
|
178
|
+
row = line.chomp.split( @app_delim )
|
178
179
|
@data << row
|
179
180
|
end
|
180
181
|
$valid_array = true
|
@@ -186,8 +187,8 @@ module Cmdapp
|
|
186
187
|
raise "Cannot save array! Please use load_array to load" if $valid_array == false
|
187
188
|
|
188
189
|
File.open(@app_file_path, "w") do |file|
|
189
|
-
|
190
|
-
@data.each { |row| file.puts
|
190
|
+
#@data.each { |row| file.puts "#{row[0]}\t#{row[1]}" }
|
191
|
+
@data.each { |row| file.puts row.join(@app_delim) }
|
191
192
|
end
|
192
193
|
end
|
193
194
|
##
|
@@ -342,6 +343,40 @@ def history_save column, str
|
|
342
343
|
f << $history_hash.to_yaml
|
343
344
|
end
|
344
345
|
end
|
346
|
+
# separates args to list-like operations
|
347
|
+
# +xxx means xxx should match in output
|
348
|
+
# -xxx means xxx should not exist in output
|
349
|
+
# @param [Array] list of search terms to match or not-match
|
350
|
+
# @return [Array, Array] array of terms that should match, and array of terms
|
351
|
+
# that should not match.
|
352
|
+
def _list_args args
|
353
|
+
incl = []
|
354
|
+
excl = []
|
355
|
+
args.each do |e|
|
356
|
+
if e[0] == '+'
|
357
|
+
incl << e[1..-1]
|
358
|
+
elsif e[0] == '-'
|
359
|
+
excl << e[1..-1]
|
360
|
+
else
|
361
|
+
incl << e
|
362
|
+
end
|
363
|
+
end
|
364
|
+
incl = nil if incl.empty?
|
365
|
+
excl = nil if excl.empty?
|
366
|
+
return incl, excl
|
367
|
+
end
|
368
|
+
##
|
369
|
+
# creates a regexp and for each row returns the row and the regexp
|
370
|
+
# you can use the regexp on whatever part of the row you want to match or reject
|
371
|
+
def filter_rows rows, incl
|
372
|
+
if incl
|
373
|
+
incl_str = incl.join "|"
|
374
|
+
r = Regexp.new incl_str
|
375
|
+
#rows = rows.select { |row| row['title'] =~ r }
|
376
|
+
rows = rows.select { |row| yield(row, r) }
|
377
|
+
end
|
378
|
+
rows
|
379
|
+
end
|
345
380
|
|
346
381
|
|
347
382
|
|
File without changes
|
@@ -73,30 +73,6 @@ module Database
|
|
73
73
|
return nil if rows.empty?
|
74
74
|
return rows
|
75
75
|
end
|
76
|
-
##
|
77
|
-
# insert a issue or bug report into the database
|
78
|
-
# @params
|
79
|
-
# @return [Fixnum] last row id
|
80
|
-
def bugs_insert(status, severity, type, assigned_to, start_date, due_date, comment_count, priority, title, description, fix, created_by = $default_user)
|
81
|
-
# id = $num
|
82
|
-
# status = "CODE"
|
83
|
-
# severity = "CODE"
|
84
|
-
# type = "CODE"
|
85
|
-
# assigned_to = "CODE"
|
86
|
-
# start_date = $now
|
87
|
-
# due_date = $now
|
88
|
-
# comment_count = $num
|
89
|
-
# priority = "CODE"
|
90
|
-
# title = "CODE"
|
91
|
-
# description = "Some long text"
|
92
|
-
# fix = "Some long text"
|
93
|
-
# date_created = $now
|
94
|
-
# date_modified = $now
|
95
|
-
@db.execute(" insert into bugs ( status, severity, type, assigned_to, start_date, due_date, comment_count, priority, title, description, fix, created_by ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
96
|
-
status, severity, type, assigned_to, start_date, due_date, comment_count, priority, title, description, fix, created_by )
|
97
|
-
rowid = @db.get_first_value( "select last_insert_rowid();")
|
98
|
-
return rowid
|
99
|
-
end
|
100
76
|
## takes a hash and creates an insert statement for table and inserts data.
|
101
77
|
# Advantage is that as we add columns, this will add the column to the insert, so we
|
102
78
|
# don't need to keep modifying in many places.
|
@@ -123,8 +99,8 @@ module Database
|
|
123
99
|
rowid = @db.get_first_value( "select last_insert_rowid();")
|
124
100
|
return rowid
|
125
101
|
end
|
126
|
-
def max_bug_id
|
127
|
-
id = @db.get_first_value( "select max(id) from
|
102
|
+
def max_bug_id table="bugs"
|
103
|
+
id = @db.get_first_value( "select max(id) from #{table};")
|
128
104
|
return id
|
129
105
|
end
|
130
106
|
def sql_comments_insert id, comment, created_by = $default_user
|
@@ -201,14 +177,14 @@ module Database
|
|
201
177
|
end
|
202
178
|
def dummy
|
203
179
|
id = $num
|
204
|
-
status = "
|
205
|
-
severity = "
|
206
|
-
type = "
|
180
|
+
status = "open"
|
181
|
+
severity = "critical"
|
182
|
+
type = "bug"
|
207
183
|
assigned_to = "rahul"
|
208
184
|
start_date = $now
|
209
185
|
due_date = $now
|
210
186
|
comment_count = 0
|
211
|
-
priority = "
|
187
|
+
priority = "P1"
|
212
188
|
title = "some title"
|
213
189
|
description = "Some long text fro this bug too"
|
214
190
|
fix = nil #"Some long text"
|
File without changes
|
data/lib/bugzyrb.rb
CHANGED
@@ -10,25 +10,25 @@
|
|
10
10
|
=end
|
11
11
|
require 'rubygems'
|
12
12
|
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
13
|
-
require 'common/colorconstants'
|
14
|
-
require 'common/sed'
|
15
|
-
require 'common/cmdapp'
|
13
|
+
require 'bugzyrb/common/colorconstants'
|
14
|
+
require 'bugzyrb/common/sed'
|
15
|
+
require 'bugzyrb/common/cmdapp'
|
16
16
|
require 'subcommand'
|
17
17
|
require 'sqlite3'
|
18
18
|
require 'highline/import'
|
19
|
-
require 'common/db'
|
19
|
+
require 'bugzyrb/common/db'
|
20
20
|
include ColorConstants
|
21
21
|
include Sed
|
22
22
|
include Cmdapp
|
23
23
|
include Subcommands
|
24
24
|
include Database
|
25
25
|
|
26
|
-
PRI_A = YELLOW + BOLD
|
27
|
-
PRI_B = WHITE + BOLD
|
28
|
-
PRI_C = GREEN + BOLD
|
29
|
-
PRI_D = CYAN + BOLD
|
30
|
-
VERSION = "0.
|
31
|
-
DATE = "2010-
|
26
|
+
#PRI_A = YELLOW + BOLD
|
27
|
+
#PRI_B = WHITE + BOLD
|
28
|
+
#PRI_C = GREEN + BOLD
|
29
|
+
#PRI_D = CYAN + BOLD
|
30
|
+
VERSION = "0.2.0"
|
31
|
+
DATE = "2010-07-24"
|
32
32
|
APPNAME = File.basename($0)
|
33
33
|
AUTHOR = "rkumar"
|
34
34
|
|
@@ -63,6 +63,7 @@ class Bugzy
|
|
63
63
|
# For more:
|
64
64
|
# $ bugzyrb --help
|
65
65
|
# $ bugzyrb --show-actions
|
66
|
+
# $ alias bu='bugzyrb'
|
66
67
|
#
|
67
68
|
# == TODO:
|
68
69
|
#
|
@@ -213,7 +214,6 @@ SQL
|
|
213
214
|
#fix = nil
|
214
215
|
body['start_date'] = @now
|
215
216
|
body['due_date'] = default_due_date
|
216
|
-
#rowid = db.bugs_insert(status, severity, type, assigned_to, start_date, due_date, comment_count, priority, title, description, fix)
|
217
217
|
rowid = db.table_insert_hash("bugs", body)
|
218
218
|
puts "Issue #{rowid} created"
|
219
219
|
type = body['type']
|
@@ -311,7 +311,6 @@ SQL
|
|
311
311
|
body["component"]=component if $use_component
|
312
312
|
body["version"]=version if $use_version
|
313
313
|
|
314
|
-
#rowid = db.bugs_insert(status, severity, type, assigned_to, start_date, due_date, comment_count, priority, title, description, fix)
|
315
314
|
rowid = db.table_insert_hash("bugs", body)
|
316
315
|
puts "Issue #{rowid} created"
|
317
316
|
logid = db.sql_logs_insert rowid, "create", "#{rowid} #{type}: #{title}"
|
@@ -441,19 +440,29 @@ TEXT
|
|
441
440
|
end
|
442
441
|
# deletes given issue
|
443
442
|
# @param [Array] id of issue
|
443
|
+
# @example
|
444
|
+
# bu delete 1
|
445
|
+
# bu $0 delete 2 3 4
|
446
|
+
# bu $0 delete $(jot - 6 10)
|
444
447
|
def delete args
|
445
|
-
id = args.shift
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
448
|
+
#id = args.shift
|
449
|
+
ctr = 0
|
450
|
+
args.each do |id|
|
451
|
+
if @options[:force]
|
452
|
+
db, row = validate_id id, false
|
453
|
+
db.sql_delete_bug id
|
454
|
+
ctr += 1
|
455
|
+
else
|
456
|
+
db, row = validate_id id, true
|
457
|
+
if agree("Delete issue #{id}? ")
|
458
|
+
db.sql_delete_bug id
|
459
|
+
ctr += 1
|
460
|
+
else
|
461
|
+
message "Operation cancelled"
|
462
|
+
end
|
463
|
+
end
|
456
464
|
end
|
465
|
+
message "#{ctr} issue/s deleted"
|
457
466
|
0
|
458
467
|
end
|
459
468
|
def copy args
|
@@ -504,19 +513,7 @@ TEXT
|
|
504
513
|
# list -- -linux
|
505
514
|
def list args
|
506
515
|
# lets look at args as search words
|
507
|
-
incl =
|
508
|
-
excl = []
|
509
|
-
args.each do |e|
|
510
|
-
if e[0] == '+'
|
511
|
-
incl << e[1..-1]
|
512
|
-
elsif e[0] == '-'
|
513
|
-
excl << e[1..-1]
|
514
|
-
else
|
515
|
-
incl << e
|
516
|
-
end
|
517
|
-
end
|
518
|
-
incl = nil if incl.empty?
|
519
|
-
excl = nil if excl.empty?
|
516
|
+
incl, excl = Cmdapp._list_args args
|
520
517
|
db = get_db
|
521
518
|
#db.run "select * from bugs " do |row|
|
522
519
|
#end
|
@@ -547,15 +544,11 @@ TEXT
|
|
547
544
|
rows = db.run "select #{fields} from bugs #{wherestring} "
|
548
545
|
die "No rows" unless rows
|
549
546
|
|
550
|
-
|
551
|
-
|
552
|
-
r = Regexp.new incl_str
|
553
|
-
rows = rows.select { |row| row['title'] =~ r }
|
547
|
+
rows = Cmdapp.filter_rows( rows, incl) do |row, regexp|
|
548
|
+
row['title'] =~ regexp
|
554
549
|
end
|
555
|
-
|
556
|
-
|
557
|
-
r = Regexp.new excl_str
|
558
|
-
rows = rows.select { |row| row['title'] !~ r }
|
550
|
+
rows = Cmdapp.filter_rows( rows, excl) do |row, regexp|
|
551
|
+
row['title'] !~ regexp
|
559
552
|
end
|
560
553
|
headings = fields.split ","
|
561
554
|
# if you want to filter output send a delimiter
|
@@ -717,7 +710,11 @@ TEXT
|
|
717
710
|
if respond_to? meth
|
718
711
|
#bool = send("validate_#{field}".to_sym, value)
|
719
712
|
bool = send(meth, value)
|
720
|
-
|
713
|
+
# try to find out values
|
714
|
+
#vfield = "@valid_#{field}"
|
715
|
+
#valid = eval(vfield).join(",")
|
716
|
+
#die "#{value} is not valid for #{field} (#{valid})" unless bool
|
717
|
+
return 1 unless bool
|
721
718
|
end
|
722
719
|
args.each do |id|
|
723
720
|
db, row = validate_id id
|
@@ -735,6 +732,14 @@ TEXT
|
|
735
732
|
end
|
736
733
|
0
|
737
734
|
end
|
735
|
+
def status args
|
736
|
+
value = args.shift
|
737
|
+
ret = change_value "status", value, args
|
738
|
+
if ret != 0
|
739
|
+
die "#{value} is not valid for status. Valid are (#{@valid_status.join(',')})"
|
740
|
+
end
|
741
|
+
0
|
742
|
+
end
|
738
743
|
# close an issue (changes status of issue/s)
|
739
744
|
# @param [Array] array of id's to close (argv)
|
740
745
|
# @return [0] for success
|
@@ -861,6 +866,10 @@ TEXT
|
|
861
866
|
return tag, items
|
862
867
|
end
|
863
868
|
|
869
|
+
# get choice from user from a list of options
|
870
|
+
# @param [String] prompt text
|
871
|
+
# @param [Array] values to chose from
|
872
|
+
# FIXME: move to Cmdapp
|
864
873
|
def _choice prompt, choices
|
865
874
|
choose do |menu|
|
866
875
|
menu.prompt = prompt
|
@@ -877,6 +886,7 @@ TEXT
|
|
877
886
|
# @return [String, nil] users choice
|
878
887
|
#
|
879
888
|
# TODO: should we not check for the ask_x methods and call them if present.
|
889
|
+
# FIXME: move to Cmdapp
|
880
890
|
def user_input column, prompt_flag, prompt_text=nil, choices=nil, default=nil
|
881
891
|
if prompt_flag == true
|
882
892
|
prompt_flag = :freeform
|
@@ -895,11 +905,11 @@ TEXT
|
|
895
905
|
when :multiline, :ml
|
896
906
|
return Cmdapp::edit_text default
|
897
907
|
when false
|
898
|
-
#return nil
|
899
908
|
return default
|
900
909
|
end
|
901
910
|
end
|
902
911
|
def test args=nil
|
912
|
+
puts "This is only for testing things out"
|
903
913
|
if $use_project
|
904
914
|
project = user_input('project', $prompt_project, nil, $valid_project, $default_project)
|
905
915
|
puts project
|
@@ -910,9 +920,10 @@ TEXT
|
|
910
920
|
end
|
911
921
|
end
|
912
922
|
## prompts user for multiline input
|
923
|
+
# NOTE: we do not take Ctrl-d as EOF then causes an error in next input in 1.9 (not 1.8)
|
913
924
|
# @param [String] text to use as prompt
|
914
925
|
# @return [String, nil] string with newlines or nil (if nothing entered).
|
915
|
-
#
|
926
|
+
# FIXME: move to Cmdapp
|
916
927
|
def get_lines prompt=nil
|
917
928
|
#prompt ||= "Enter multiple lines, to quit enter . on empty line"
|
918
929
|
#message prompt
|
@@ -927,6 +938,9 @@ TEXT
|
|
927
938
|
return nil if str == ""
|
928
939
|
return str.chomp
|
929
940
|
end
|
941
|
+
# get a string from user, using readline or gets
|
942
|
+
# if readline, then manage column specific history
|
943
|
+
# FIXME: move to Cmdapp.
|
930
944
|
def _gets column, prompt, default=nil
|
931
945
|
text = "#{prompt}? "
|
932
946
|
text << "|#{default}|" if default
|
@@ -1169,16 +1183,17 @@ TEXT
|
|
1169
1183
|
#}
|
1170
1184
|
end
|
1171
1185
|
Subcommands::command :status do |opts|
|
1172
|
-
opts.banner = "Usage: status [options] <STATUS> <
|
1173
|
-
opts.description = "Change the status of
|
1174
|
-
opts.on("--recursive", "operate on subtasks also") { |v|
|
1175
|
-
options[:recursive] = v
|
1176
|
-
}
|
1177
|
-
end
|
1178
|
-
Subcommands::command :tag do |opts|
|
1179
|
-
opts.banner = "Usage: tag <TAG> <TASKS>"
|
1180
|
-
opts.description = "Add a tag to an item/s. "
|
1186
|
+
opts.banner = "Usage: status [options] <STATUS> <ISSUE>"
|
1187
|
+
opts.description = "Change the status of an issue. \t<STATUS> are open closed started canceled stopped "
|
1188
|
+
#opts.on("--recursive", "operate on subtasks also") { |v|
|
1189
|
+
#options[:recursive] = v
|
1190
|
+
#}
|
1181
1191
|
end
|
1192
|
+
# TODO:
|
1193
|
+
#Subcommands::command :tag do |opts|
|
1194
|
+
#opts.banner = "Usage: tag <TAG> <TASKS>"
|
1195
|
+
#opts.description = "Add a tag to an item/s. "
|
1196
|
+
#end
|
1182
1197
|
#Subcommands::alias_command :open , "status","open"
|
1183
1198
|
#Subcommands::alias_command :close , "status","closed"
|
1184
1199
|
cmd = Subcommands::opt_parse()
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Rahul Kumar
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-09 00:00:00 +05:30
|
18
18
|
default_executable: bugzyrb
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -121,10 +121,10 @@ files:
|
|
121
121
|
- bugzy.cfg
|
122
122
|
- bugzyrb.gemspec
|
123
123
|
- lib/bugzyrb.rb
|
124
|
-
- lib/common/cmdapp.rb
|
125
|
-
- lib/common/colorconstants.rb
|
126
|
-
- lib/common/db.rb
|
127
|
-
- lib/common/sed.rb
|
124
|
+
- lib/bugzyrb/common/cmdapp.rb
|
125
|
+
- lib/bugzyrb/common/colorconstants.rb
|
126
|
+
- lib/bugzyrb/common/db.rb
|
127
|
+
- lib/bugzyrb/common/sed.rb
|
128
128
|
has_rdoc: true
|
129
129
|
homepage: http://github.com/rkumar/bugzyrb
|
130
130
|
licenses: []
|