feat(export): add --id and --parent filters (#1292)
Add two new filter flags to the export command: - --id: Filter by specific issue IDs (comma-separated) - --parent: Filter by parent issue ID (shows children) Also fix safety checks (empty DB, staleness) to skip when filters are active, since filtered exports intentionally produce subsets. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
e45a7489b2
commit
4669de7625
@@ -150,6 +150,8 @@ Examples:
|
||||
createdBefore, _ := cmd.Flags().GetString("created-before")
|
||||
updatedAfter, _ := cmd.Flags().GetString("updated-after")
|
||||
updatedBefore, _ := cmd.Flags().GetString("updated-before")
|
||||
idFilter, _ := cmd.Flags().GetString("id")
|
||||
parentID, _ := cmd.Flags().GetString("parent")
|
||||
|
||||
debug.Logf("Debug: export flags - output=%q, force=%v\n", output, force)
|
||||
|
||||
@@ -225,6 +227,15 @@ Examples:
|
||||
if len(labelsAny) > 0 {
|
||||
filter.LabelsAny = labelsAny
|
||||
}
|
||||
if idFilter != "" {
|
||||
ids := util.NormalizeLabels(strings.Split(idFilter, ","))
|
||||
if len(ids) > 0 {
|
||||
filter.IDs = ids
|
||||
}
|
||||
}
|
||||
if parentID != "" {
|
||||
filter.ParentID = &parentID
|
||||
}
|
||||
|
||||
// Priority exact match (use Changed() to properly handle P0)
|
||||
if cmd.Flags().Changed("priority") {
|
||||
@@ -297,8 +308,27 @@ Examples:
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Detect if any substantive filters are active (partial export)
|
||||
// Safety checks should be skipped for filtered exports since the user
|
||||
// intentionally wants a subset of issues, not the full database
|
||||
isFilteredExport := filter.Status != nil ||
|
||||
filter.Assignee != nil ||
|
||||
filter.IssueType != nil ||
|
||||
len(filter.Labels) > 0 ||
|
||||
len(filter.LabelsAny) > 0 ||
|
||||
len(filter.IDs) > 0 ||
|
||||
filter.ParentID != nil ||
|
||||
filter.Priority != nil ||
|
||||
filter.PriorityMin != nil ||
|
||||
filter.PriorityMax != nil ||
|
||||
filter.CreatedAfter != nil ||
|
||||
filter.CreatedBefore != nil ||
|
||||
filter.UpdatedAfter != nil ||
|
||||
filter.UpdatedBefore != nil
|
||||
|
||||
// Safety check: prevent exporting empty database over non-empty JSONL
|
||||
if len(issues) == 0 && output != "" && !force {
|
||||
// Skip this check for filtered exports - the user intentionally wants a subset
|
||||
if len(issues) == 0 && output != "" && !force && !isFilteredExport {
|
||||
existingCount, err := countIssuesInJSONL(output)
|
||||
if err != nil {
|
||||
// If we can't read the file, it might not exist yet, which is fine
|
||||
@@ -317,7 +347,8 @@ Examples:
|
||||
}
|
||||
|
||||
// Safety check: prevent exporting stale database that would lose issues
|
||||
if output != "" && !force {
|
||||
// Skip this check for filtered exports - the user intentionally wants a subset
|
||||
if output != "" && !force && !isFilteredExport {
|
||||
debug.Logf("Debug: checking staleness - output=%s, force=%v\n", output, force)
|
||||
|
||||
// Read existing JSONL to get issue IDs
|
||||
@@ -616,5 +647,11 @@ func init() {
|
||||
exportCmd.Flags().String("updated-after", "", "Filter issues updated after date (YYYY-MM-DD or RFC3339)")
|
||||
exportCmd.Flags().String("updated-before", "", "Filter issues updated before date (YYYY-MM-DD or RFC3339)")
|
||||
|
||||
// ID filter
|
||||
exportCmd.Flags().String("id", "", "Filter by specific issue IDs (comma-separated, e.g., bd-1,bd-5,bd-10)")
|
||||
|
||||
// Parent filter
|
||||
exportCmd.Flags().String("parent", "", "Filter by parent issue ID (shows children of specified issue)")
|
||||
|
||||
rootCmd.AddCommand(exportCmd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user