本文整理匯總了Golang中github.com/driusan/bug/bugs.Bug.SetIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:Golang Bug.SetIdentifier方法的具體用法?Golang Bug.SetIdentifier怎麽用?Golang Bug.SetIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/driusan/bug/bugs.Bug
的用法示例。
在下文中一共展示了Bug.SetIdentifier方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Create
func Create(Args ArgumentList) {
if len(Args) < 1 || (len(Args) < 2 && Args[0] == "-n") {
fmt.Fprintf(os.Stderr, "Usage: %s create [-n] Bug Description\n", os.Args[0])
fmt.Fprintf(os.Stderr, "\nNo Bug Description provided.\n")
return
}
var noDesc bool = false
if Args.HasArgument("-n") {
noDesc = true
Args = Args[1:]
}
Args, argVals := Args.GetAndRemoveArguments([]string{"--tag", "--status", "--priority", "--milestone", "--identifier"})
tag := argVals[0]
status := argVals[1]
priority := argVals[2]
milestone := argVals[3]
identifier := argVals[4]
if Args.HasArgument("--generate-id") {
for i, token := range Args {
if token == "--generate-id" {
if i+1 < len(Args) {
Args = append(Args[:i], Args[i+1:]...)
break
} else {
Args = Args[:i]
break
}
}
}
identifier = generateID(strings.Join(Args, " "))
}
var bug bugs.Bug
bug = bugs.Bug{
Dir: bugs.GetIssuesDir() + bugs.TitleToDir(strings.Join(Args, " ")),
}
dir := bug.GetDirectory()
var mode os.FileMode
mode = 0775
os.Mkdir(string(dir), mode)
if noDesc {
txt := []byte("")
ioutil.WriteFile(string(dir)+"/Description", txt, 0644)
} else {
cmd := exec.Command(getEditor(), string(dir)+"/Description")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
}
if tag != "" {
bug.TagBug(bugs.Tag(tag))
}
if status != "" {
bug.SetStatus(status)
}
if priority != "" {
bug.SetPriority(priority)
}
if milestone != "" {
bug.SetMilestone(milestone)
}
if identifier != "" {
bug.SetIdentifier(identifier)
}
fmt.Printf("Created issue: %s\n", bug.Title(""))
}
示例2: beImportBug
func beImportBug(identifier, issuesDir, fullbepath string) {
/* BE appears to store the top level data of a bug
ins a json file named values with the format:
{
"creator": "Dave MacFarlane <[email protected]>",
"reporter": "Dave MacFarlane <[email protected]>",
"severity": "minor",
"status": "open",
"summary": "abc",
"time": "Tue, 12 Jan 2016 00:05:28 +0000"
}
and the description of bugs entirely in comments.
All we really care about is the summary so that we
can get the directory name for the issues/ directory,
but the severity+status can also be used as a status
to ensure that we have at least 1 file to be tracked
by git.
*/
type BeValues struct {
Creator string `json:creator`
Reporter string `json:reporter`
Severity string `json:severity`
Status string `json:status`
Summary string `json:summary`
Time string `json:time`
}
file := fullbepath + "/values"
fmt.Printf("File: %s\n", file)
data, _ := ioutil.ReadFile(file)
var beBug BeValues
err := json.Unmarshal([]byte(data), &beBug)
if err != nil {
fmt.Printf("Error unmarshalling data: %s\n", err.Error())
}
fmt.Printf("%s\n", beBug)
bugdir := bugs.TitleToDir(beBug.Summary)
b := bugs.Bug{bugs.Directory(issuesDir) + bugdir}
if dir := b.GetDirectory(); dir != "" {
os.Mkdir(string(dir), 0755)
}
if beBug.Status != "" && beBug.Severity != "" {
b.SetStatus(beBug.Status + ":" + beBug.Severity)
}
comments := fullbepath + "/comments/"
dir, err := os.Open(comments)
files, err := dir.Readdir(-1)
var Description string
if len(files) > 0 && err == nil {
for _, file := range files {
if file.IsDir() {
Description = Description + "\n" +
beImportComments(b, comments+file.Name(), len(files) > 1)
}
}
}
b.SetDescription(Description)
b.SetIdentifier(identifier)
}