HG corrupted local copy, lost 22 changesets
This commit is contained in:
@ -3,8 +3,7 @@ package com.jdbernard.pit
|
||||
public enum Category {
|
||||
BUG,
|
||||
FEATURE,
|
||||
TASK,
|
||||
CLOSED
|
||||
TASK
|
||||
|
||||
public static Category toCategory(String s) {
|
||||
for(c in Category.values())
|
||||
|
@ -5,19 +5,21 @@ import java.lang.IllegalArgumentException as IAE
|
||||
public class FileIssue extends Issue {
|
||||
|
||||
protected File source
|
||||
public static final String fileExp = /(\d+)([bft])([ajnsv])(\d).*/
|
||||
|
||||
public FileIssue(File file) {
|
||||
|
||||
super('REPLACE_ME')
|
||||
|
||||
def matcher = file.name =~ /(\d{4})([bftc])(\d).*/
|
||||
def matcher = file.name =~ fileExp
|
||||
if (!matcher)
|
||||
throw new IllegalArgumentException("${file} " +
|
||||
"is not a valid Issue file.")
|
||||
|
||||
super.@id = matcher[0][1]
|
||||
super.@category = Category.toCategory(matcher[0][2])
|
||||
super.@priority = matcher[0][3].toInteger()
|
||||
super.@status = Status.toStatus(matcher[0][3])
|
||||
super.@priority = matcher[0][4].toInteger()
|
||||
|
||||
this.source = file
|
||||
|
||||
@ -29,12 +31,19 @@ public class FileIssue extends Issue {
|
||||
source.renameTo(new File(source.canonicalFile.parentFile, getFilename()))
|
||||
}
|
||||
|
||||
public void setStatus(Status s) {
|
||||
super.setStatus(s)
|
||||
source.renameTo(new File(source.canonicalFile.parentFile, getFilename()))
|
||||
}
|
||||
|
||||
public void setPriority(int p) {
|
||||
super.setPriority(p)
|
||||
source.renameTo(new File(source.canonicalFile.parentFile, getFilename()))
|
||||
}
|
||||
|
||||
public String getFilename() { return makeFilename(id, category, priority) }
|
||||
public String getFilename() {
|
||||
return makeFilename(id, category, status, priority)
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
super.setText(text)
|
||||
@ -44,11 +53,11 @@ public class FileIssue extends Issue {
|
||||
public boolean delete() { return source.delete() }
|
||||
|
||||
public static boolean isValidFilename(String name) {
|
||||
return name ==~ /(\d+)([bcft])(\d).*/
|
||||
return name ==~ fileExp
|
||||
}
|
||||
|
||||
public static String makeFilename(String id, Category category,
|
||||
int priority) {
|
||||
Status status, int priority) {
|
||||
|
||||
// bounds check priority
|
||||
priority = Math.min(9, Math.max(0, priority))
|
||||
@ -56,10 +65,12 @@ public class FileIssue extends Issue {
|
||||
//check for valid values of cateogry and id
|
||||
if (category == null)
|
||||
throw new IAE("Category must be non-null.")
|
||||
if (status == null)
|
||||
throw new IAE("Status must be non-null.")
|
||||
if (!(id ==~ /\d+/))
|
||||
throw new IAE( "'${id}' is not a legal value for id.")
|
||||
|
||||
return id + category.symbol + priority + ".rst";
|
||||
return id + category.symbol + status.symbol + priority + ".rst";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class FileProject extends Project {
|
||||
|
||||
// add sub projects
|
||||
if (child.isDirectory()) {
|
||||
if ( child.name ==~ /\d{4}/) return // just an issue folder
|
||||
if ( child.name ==~ /\d+/) return // just an issue folder
|
||||
|
||||
// otherwise build and add to list
|
||||
projects[(child.name)] = new FileProject(child)
|
||||
@ -41,6 +41,7 @@ class FileProject extends Project {
|
||||
public FileIssue createNewIssue(Map options) {
|
||||
if (!options) options = [:]
|
||||
if (!options.category) options.category = Category.TASK
|
||||
if (!options.status) options.status = Status.NEW
|
||||
if (!options.priority) options.priority = 5
|
||||
if (!options.text) options.text = "Default issue title.\n" +
|
||||
"====================\n"
|
||||
@ -52,7 +53,7 @@ class FileProject extends Project {
|
||||
}
|
||||
|
||||
def issueFile = new File(source, FileIssue.makeFilename(id,
|
||||
options.category, options.priority))
|
||||
options.category, options.status, options.priority))
|
||||
|
||||
issueFile.createNewFile()
|
||||
issueFile.write(options.text)
|
||||
|
@ -3,6 +3,7 @@ package com.jdbernard.pit
|
||||
class Filter {
|
||||
|
||||
List<Category> categories = null
|
||||
List<Status> status = null
|
||||
List<String> projects = null
|
||||
List<String> ids = null
|
||||
int priority = 9
|
||||
@ -16,6 +17,7 @@ class Filter {
|
||||
public boolean accept(Issue i) {
|
||||
return (i.priority <= priority &&
|
||||
(!categories || categories.contains(i.category)) &&
|
||||
(!status || status.contains(i.status)) &&
|
||||
(!ids || ids.contains(i.id)))
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,15 @@ public abstract class Issue {
|
||||
|
||||
protected String id
|
||||
protected Category category
|
||||
protected Status status
|
||||
protected int priority
|
||||
protected String text
|
||||
|
||||
Issue(String id, Category c = Category.TASK, int p = 9) {
|
||||
Issue(String id, Category c = Category.TASK, Status s = Status.NEW,
|
||||
int p = 9) {
|
||||
this.id = id
|
||||
this.category = c
|
||||
this.status = s
|
||||
this.priority = p
|
||||
}
|
||||
|
||||
@ -26,6 +29,15 @@ public abstract class Issue {
|
||||
this.category = c
|
||||
}
|
||||
|
||||
public Status getStatus() { return status }
|
||||
|
||||
public void setStatus(Status s) {
|
||||
if (s == null)
|
||||
throw new IAE("Status cannot be null.")
|
||||
|
||||
this.status = s
|
||||
}
|
||||
|
||||
public int getPriority() { return priority }
|
||||
|
||||
public void setPriority(int p) { priority = Math.min(9, Math.max(0, p)) }
|
||||
@ -37,7 +49,7 @@ public abstract class Issue {
|
||||
public void setText(String t) { text = t }
|
||||
|
||||
@Override
|
||||
public String toString() { return "${id}(${priority}): ${category} ${title}" }
|
||||
public String toString() { return "${id}(${priority}-${status}): ${category} ${title}" }
|
||||
|
||||
public abstract boolean delete()
|
||||
}
|
||||
|
41
libpit/src/com/jdbernard/pit/Status.groovy
Normal file
41
libpit/src/com/jdbernard/pit/Status.groovy
Normal file
@ -0,0 +1,41 @@
|
||||
package com.jdbernard.pit
|
||||
|
||||
public enum Status {
|
||||
REASSIGNED('a'),
|
||||
REJECTED('j'),
|
||||
NEW('n'),
|
||||
RESOLVED('s'),
|
||||
VALIDATION_REQUIRED('v')
|
||||
|
||||
String symbol
|
||||
|
||||
protected Status(String s) { symbol = s }
|
||||
|
||||
public static Status toStatus(String str) {
|
||||
Status retVal = null
|
||||
for(status in Status.values()) {
|
||||
if (status.symbol.equalsIgnoreCase(str) ||
|
||||
status.name().startsWith(str.toUpperCase())) {
|
||||
|
||||
if (retVal != null)
|
||||
throw new IllegalArgumentException("Request string is" +
|
||||
" ambigous, '${str}' could represent ${retVal} or " +
|
||||
"${status}, possibly others.")
|
||||
|
||||
retVal = status
|
||||
}
|
||||
}
|
||||
|
||||
if (retVal == null)
|
||||
throw new IllegalArgumentException("No status matches '${str}'")
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
def words = name().split("_")
|
||||
String result = ""
|
||||
words.each { result += "${it[0]}${it[1..-1].toLowerCase()} " }
|
||||
return result[0..-2]
|
||||
}
|
||||
}
|
36
libpit/src/com/jdbernard/pit/util/Convert1_2.groovy
Normal file
36
libpit/src/com/jdbernard/pit/util/Convert1_2.groovy
Normal file
@ -0,0 +1,36 @@
|
||||
package com.jdbernard.pit.util
|
||||
|
||||
import com.jdbernard.pit.*
|
||||
|
||||
if (args.size() != 1) {
|
||||
println "Usage: Convert1_2 [dir]"
|
||||
System.exit(1)
|
||||
}
|
||||
|
||||
File rootDir = new File(args[0])
|
||||
Scanner scan = new Scanner(System.in)
|
||||
|
||||
rootDir.eachFileRecurse { file ->
|
||||
def m = file.name =~ /(\d+)([bcft])(\d).*/
|
||||
if (m && file.isFile()) {
|
||||
println m[0][0]
|
||||
def parentFile = file.canonicalFile.parentFile
|
||||
def c
|
||||
def s
|
||||
switch(m[0][2]) {
|
||||
case "c":
|
||||
println file.readLines()[0]
|
||||
print "Issue was closed, was category does it belong in?"
|
||||
c = Category.toCategory(scan.nextLine())
|
||||
s = Status.RESOLVED
|
||||
break
|
||||
default:
|
||||
c = Category.toCategory(m[0][2])
|
||||
s = Status.NEW
|
||||
break
|
||||
}
|
||||
println "${m[0][2]}: ${c}"
|
||||
file.renameTo(new File(parentFile,
|
||||
FileIssue.makeFilename(m[0][1], c, s, m[0][3].toInteger())))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user