diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/bash_completion/git-bug | 84 | ||||
-rw-r--r-- | misc/gen_bash_completion.go | 7 | ||||
-rw-r--r-- | misc/gen_zsh_completion.go | 3 | ||||
-rw-r--r-- | misc/random_bugs/create_random_bugs.go | 60 | ||||
-rw-r--r-- | misc/random_bugs/main.go | 2 | ||||
-rw-r--r-- | misc/zsh_completion/git-bug | 5 |
6 files changed, 127 insertions, 34 deletions
diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug index 8551223d..a0ac545c 100644 --- a/misc/bash_completion/git-bug +++ b/misc/bash_completion/git-bug @@ -799,6 +799,89 @@ _git-bug_title() noun_aliases=() } +_git-bug_user_adopt() +{ + last_command="git-bug_user_adopt" + + command_aliases=() + + commands=() + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + +_git-bug_user_create() +{ + last_command="git-bug_user_create" + + command_aliases=() + + commands=() + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + +_git-bug_user_ls() +{ + last_command="git-bug_user_ls" + + command_aliases=() + + commands=() + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + +_git-bug_user() +{ + last_command="git-bug_user" + + command_aliases=() + + commands=() + commands+=("adopt") + commands+=("create") + commands+=("ls") + + flags=() + two_word_flags=() + local_nonpersistent_flags=() + flags_with_completion=() + flags_completion=() + + + must_have_one_flag=() + must_have_one_noun=() + noun_aliases=() +} + _git-bug_version() { last_command="git-bug_version" @@ -874,6 +957,7 @@ _git-bug_root_command() commands+=("status") commands+=("termui") commands+=("title") + commands+=("user") commands+=("version") commands+=("webui") diff --git a/misc/gen_bash_completion.go b/misc/gen_bash_completion.go index 8793556a..f2506606 100644 --- a/misc/gen_bash_completion.go +++ b/misc/gen_bash_completion.go @@ -4,19 +4,20 @@ package main import ( "fmt" - "github.com/MichaelMure/git-bug/commands" "log" "os" "path" + + "github.com/MichaelMure/git-bug/commands" ) func main() { cwd, _ := os.Getwd() - filepath := path.Join(cwd, "misc", "bash_completion", "git-bug") + dir := path.Join(cwd, "misc", "bash_completion", "git-bug") fmt.Println("Generating bash completion file ...") - err := commands.RootCmd.GenBashCompletionFile(filepath) + err := commands.RootCmd.GenBashCompletionFile(dir) if err != nil { log.Fatal(err) } diff --git a/misc/gen_zsh_completion.go b/misc/gen_zsh_completion.go index 41e08f9a..184cab43 100644 --- a/misc/gen_zsh_completion.go +++ b/misc/gen_zsh_completion.go @@ -4,10 +4,11 @@ package main import ( "fmt" - "github.com/MichaelMure/git-bug/commands" "log" "os" "path" + + "github.com/MichaelMure/git-bug/commands" ) func main() { diff --git a/misc/random_bugs/create_random_bugs.go b/misc/random_bugs/create_random_bugs.go index 8faee200..0657c808 100644 --- a/misc/random_bugs/create_random_bugs.go +++ b/misc/random_bugs/create_random_bugs.go @@ -6,11 +6,12 @@ import ( "time" "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/identity" "github.com/MichaelMure/git-bug/repository" "github.com/icrowley/fake" ) -type opsGenerator func(bug.Interface, bug.Person) +type opsGenerator func(bug.Interface, identity.Interface) type Options struct { BugNumber int @@ -33,7 +34,9 @@ func CommitRandomBugs(repo repository.ClockedRepo, opts Options) { } func CommitRandomBugsWithSeed(repo repository.ClockedRepo, opts Options, seed int64) { - bugs := GenerateRandomBugsWithSeed(opts, seed) + generateRandomPersons(repo, opts.PersonNumber) + + bugs := generateRandomBugsWithSeed(opts, seed) for _, b := range bugs { err := b.Commit(repo) @@ -43,11 +46,7 @@ func CommitRandomBugsWithSeed(repo repository.ClockedRepo, opts Options, seed in } } -func GenerateRandomBugs(opts Options) []*bug.Bug { - return GenerateRandomBugsWithSeed(opts, time.Now().UnixNano()) -} - -func GenerateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug { +func generateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug { rand.Seed(seed) fake.Seed(seed) @@ -66,7 +65,7 @@ func GenerateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug { addedLabels = []string{} b, _, err := bug.Create( - randomPerson(opts.PersonNumber), + randomPerson(), time.Now().Unix(), fake.Sentence(), paragraphs(), @@ -84,7 +83,7 @@ func GenerateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug { for j := 0; j < nOps; j++ { index := rand.Intn(len(opsGenerators)) - opsGenerators[index](b, randomPerson(opts.PersonNumber)) + opsGenerators[index](b, randomPerson()) } result[i] = b @@ -100,6 +99,9 @@ func GenerateRandomOperationPacks(packNumber int, opNumber int) []*bug.Operation func GenerateRandomOperationPacksWithSeed(packNumber int, opNumber int, seed int64) []*bug.OperationPack { // Note: this is a bit crude, only generate a Create + Comments + panic("this piece of code needs to be updated to make sure that the identities " + + "are properly commit before usage. That is, generateRandomPersons() need to be called.") + rand.Seed(seed) fake.Seed(seed) @@ -111,7 +113,7 @@ func GenerateRandomOperationPacksWithSeed(packNumber int, opNumber int, seed int var op bug.Operation op = bug.NewCreateOp( - randomPerson(5), + randomPerson(), time.Now().Unix(), fake.Sentence(), paragraphs(), @@ -122,7 +124,7 @@ func GenerateRandomOperationPacksWithSeed(packNumber int, opNumber int, seed int for j := 0; j < opNumber-1; j++ { op = bug.NewAddCommentOp( - randomPerson(5), + randomPerson(), time.Now().Unix(), paragraphs(), nil, @@ -136,24 +138,26 @@ func GenerateRandomOperationPacksWithSeed(packNumber int, opNumber int, seed int return result } -func person() bug.Person { - return bug.Person{ - Name: fake.FullName(), - Email: fake.EmailAddress(), - } +func person() identity.Interface { + return identity.NewIdentity(fake.FullName(), fake.EmailAddress()) } -var persons []bug.Person +var persons []identity.Interface -func randomPerson(personNumber int) bug.Person { - if len(persons) == 0 { - persons = make([]bug.Person, personNumber) - for i := range persons { - persons[i] = person() +func generateRandomPersons(repo repository.ClockedRepo, n int) { + persons = make([]identity.Interface, n) + for i := range persons { + p := person() + err := p.Commit(repo) + if err != nil { + panic(err) } + persons[i] = p } +} - index := rand.Intn(personNumber) +func randomPerson() identity.Interface { + index := rand.Intn(len(persons)) return persons[index] } @@ -162,25 +166,25 @@ func paragraphs() string { return strings.Replace(p, "\t", "\n\n", -1) } -func comment(b bug.Interface, p bug.Person) { +func comment(b bug.Interface, p identity.Interface) { _, _ = bug.AddComment(b, p, time.Now().Unix(), paragraphs()) } -func title(b bug.Interface, p bug.Person) { +func title(b bug.Interface, p identity.Interface) { _, _ = bug.SetTitle(b, p, time.Now().Unix(), fake.Sentence()) } -func open(b bug.Interface, p bug.Person) { +func open(b bug.Interface, p identity.Interface) { _, _ = bug.Open(b, p, time.Now().Unix()) } -func close(b bug.Interface, p bug.Person) { +func close(b bug.Interface, p identity.Interface) { _, _ = bug.Close(b, p, time.Now().Unix()) } var addedLabels []string -func labels(b bug.Interface, p bug.Person) { +func labels(b bug.Interface, p identity.Interface) { var removed []string nbRemoved := rand.Intn(3) for nbRemoved > 0 && len(addedLabels) > 0 { diff --git a/misc/random_bugs/main.go b/misc/random_bugs/main.go index 31b12e45..274b3dac 100644 --- a/misc/random_bugs/main.go +++ b/misc/random_bugs/main.go @@ -17,7 +17,7 @@ func main() { panic(err) } - repo, err := repository.NewGitRepo(dir, func(repo *repository.GitRepo) error { + repo, err := repository.NewGitRepo(dir, func(repo repository.ClockedRepo) error { return nil }) if err != nil { diff --git a/misc/zsh_completion/git-bug b/misc/zsh_completion/git-bug index a416ccef..c2ed9872 100644 --- a/misc/zsh_completion/git-bug +++ b/misc/zsh_completion/git-bug @@ -8,7 +8,7 @@ case $state in level1) case $words[1] in git-bug) - _arguments '1: :(add bridge commands comment deselect label ls ls-label pull push select show status termui title version webui)' + _arguments '1: :(add bridge commands comment deselect label ls ls-id ls-label pull push select show status termui title user version webui)' ;; *) _arguments '*: :_files' @@ -32,6 +32,9 @@ case $state in title) _arguments '2: :(edit)' ;; + user) + _arguments '2: :(adopt create ls)' + ;; *) _arguments '*: :_files' ;; |