Skip to content

Commit

Permalink
issue view - allow searching for string in title
Browse files Browse the repository at this point in the history
  • Loading branch information
3ximus committed Feb 25, 2024
1 parent ac24dc7 commit bc893cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ bb help [COMMAND]
TODO
- pr list | status filter should include options defined in config file (like issue list)
- pipeline list | status filter should include options defined in config file (like issue list)
### NOTE TO SELF
To generate documentation use this
Expand Down
8 changes: 7 additions & 1 deletion api/jira-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func GetIssue(key string) <-chan JiraIssue {
return channel
}

func GetIssueList(nResults int, all bool, reporter bool, project string, statuses []string, prioritySort bool) <-chan JiraIssue {
func GetIssueList(nResults int, all bool, reporter bool, project string, statuses []string, searchTerm string, prioritySort bool) <-chan JiraIssue {
channel := make(chan JiraIssue)
go func() {
defer close(channel)
Expand All @@ -111,6 +111,12 @@ func GetIssueList(nResults int, all bool, reporter bool, project string, statuse
}
query += fmt.Sprintf("project=%s", url.QueryEscape(project))
}
if searchTerm != "" {
if query != "" {
query += "+AND+"
}
query += fmt.Sprintf("summary~\"%s\"", url.QueryEscape(searchTerm))
}
if len(statuses) > 0 {
if query != "" {
query += "+AND+"
Expand Down
6 changes: 4 additions & 2 deletions cmd/issue/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var ListCmd = &cobra.Command{
nResults, _ := cmd.Flags().GetInt("number-results")
reporter, _ := cmd.Flags().GetBool("reporter")
all, _ := cmd.Flags().GetBool("all")
search, _ := cmd.Flags().GetString("search")
statuses, _ := cmd.Flags().GetStringArray("status")
project, _ := cmd.Flags().GetString("project")
priority, _ := cmd.Flags().GetBool("priority")
Expand Down Expand Up @@ -50,13 +51,12 @@ var ListCmd = &cobra.Command{
}
}

for issue := range api.GetIssueList(nResults, all, reporter, project, statusConversion, priority) {
for issue := range api.GetIssueList(nResults, all, reporter, project, statusConversion, search, priority) {
timeSpent := "-"
if issue.Fields.TimeTracking.TimeSpent != " " {
timeSpent = issue.Fields.TimeTracking.TimeSpent
}
util.Printf("%s \033[1;32m%s\033[m %s %s %s\n", util.FormatIssueStatus(issue.Fields.Status.Name), issue.Key, util.FormatIssueType(issue.Fields.Type.Name), issue.Fields.Summary, util.FormatIssuePriority(issue.Fields.Priority.Id, issue.Fields.Priority.Name))
// TODO format spacing better
if showUsers {
if all {
util.Printf(" \033[37mAssigned: \033[1m%s\033[0;37m -> Reporter: \033[1;36m%s\033[m \033[37m(%d comments)\033[m\n", issue.Fields.Assignee.DisplayName, issue.Fields.Reporter.DisplayName, issue.Fields.Comment.Total)
Expand All @@ -74,13 +74,15 @@ var ListCmd = &cobra.Command{
}

func init() {
// filter
ListCmd.Flags().StringP("project", "p", "", `filter issues by project key.
If "all" is given it shows all projects (when a project is detected on current branch and you still want to show all projects)`)
ListCmd.Flags().BoolP("all", "a", false, "filter all issues. (Not assigned or reporting to current user)")
ListCmd.Flags().BoolP("reporter", "r", false, "filter issues reporting to current user")
ListCmd.Flags().StringArrayP("status", "s", []string{}, `filter status type.
this option will provide completion for the mappings defined in "jira_status" of your config file`)
ListCmd.RegisterFlagCompletionFunc("status", statusCompletion)
ListCmd.Flags().String("search", "", "filter issues by keyword")

// TODO add way to sort by recent or the ones the user has participated on

Expand Down

0 comments on commit bc893cc

Please sign in to comment.