Repository: cli/cli
File: pkg/cmd/project/item-edit/item_edit.go (Go)

Code before:
		return updateItemValues(config)
	}

	if _, err := fmt.Fprintln(config.io.ErrOut, "error: no changes to make"); err != nil {
		return err
	}
	return cmdutil.SilentError
}

func buildEditDraftIssue(config editItemConfig) (*EditProjectDraftIssue, map[string]interface{}) {
	return &EditProjectDraftIssue{}, map[string]interface{}{
		"input": githubv4.UpdateProjectV2DraftIssueInput{
			Body:         githubv4.NewString(githubv4.String(config.opts.body)),
			DraftIssueID: githubv4.ID(config.opts.itemID),
			Title:        githubv4.NewString(githubv4.String(config.opts.title)),
		},
	}
}

func buildUpdateItem(config editItemConfig, date time.Time) (*UpdateProjectV2FieldValue, map[string]interface{}) {
	var value githubv4.ProjectV2FieldValue
	if config.opts.text != "" {
		value = githubv4.ProjectV2FieldValue{
			Text: githubv4.NewString(githubv4.String(config.opts.text)),
		}
	} else if config.opts.number != 0 {
		value = githubv4.ProjectV2FieldValue{
			Number: githubv4.NewFloat(githubv4.Float(config.opts.number)),
		}
	} else if config.opts.numberChanged {
		value = githubv4.ProjectV2FieldValue{
			Number: githubv4.NewFloat(githubv4.Float(config.opts.number)),
		}
	} else if config.opts.date != "" {
		value = githubv4.ProjectV2FieldValue{
			Date: githubv4.NewDate(githubv4.Date{Time: date}),
		}
	} else if config.opts.singleSelectOptionID != "" {
		value = githubv4.ProjectV2FieldValue{
			SingleSelectOptionID: githubv4.NewString(githubv4.String(config.opts.singleSelectOptionID)),
		}
	} else if config.opts.iterationID != "" {
		value = githubv4.ProjectV2FieldValue{
			IterationID: githubv4.NewString(githubv4.String(config.opts.iterationID)),
		}
	}

	return &UpdateProjectV2FieldValue{}, map[string]interface{}{
		"input": githubv4.UpdateProjectV2ItemFieldValueInput{
			ProjectID: githubv4.ID(config.opts.projectID),
			ItemID:    githubv4.ID(config.opts.itemID),

Review comment (suggestion):
**Change Requested**

It seems to me like this new branch is mostly duplicative of the branch above, in that it now says:

```
if the number is not 0
   set the value
else if the number has changed
  set the value
```

Where the second case will only get hit when the number is 0. But if we removed the first case it would say:

```
 if the number has changed
  set the value
```

Which would cover the first case.

Code after:
		return updateItemValues(config)
	}

	if _, err := fmt.Fprintln(config.io.ErrOut, "error: no changes to make"); err != nil {
		return err
	}
	return cmdutil.SilentError
}

func buildEditDraftIssue(config editItemConfig) (*EditProjectDraftIssue, map[string]interface{}) {
	return &EditProjectDraftIssue{}, map[string]interface{}{
		"input": githubv4.UpdateProjectV2DraftIssueInput{
			Body:         githubv4.NewString(githubv4.String(config.opts.body)),
			DraftIssueID: githubv4.ID(config.opts.itemID),
			Title:        githubv4.NewString(githubv4.String(config.opts.title)),
		},
	}
}

func buildUpdateItem(config editItemConfig, date time.Time) (*UpdateProjectV2FieldValue, map[string]interface{}) {
	var value githubv4.ProjectV2FieldValue
	if config.opts.text != "" {
		value = githubv4.ProjectV2FieldValue{
			Text: githubv4.NewString(githubv4.String(config.opts.text)),
		}
	} else if config.opts.numberChanged {
		value = githubv4.ProjectV2FieldValue{
			Number: githubv4.NewFloat(githubv4.Float(config.opts.number)),
		}
	} else if config.opts.date != "" {
		value = githubv4.ProjectV2FieldValue{
			Date: githubv4.NewDate(githubv4.Date{Time: date}),
		}
	} else if config.opts.singleSelectOptionID != "" {
		value = githubv4.ProjectV2FieldValue{
			SingleSelectOptionID: githubv4.NewString(githubv4.String(config.opts.singleSelectOptionID)),
		}
	} else if config.opts.iterationID != "" {
		value = githubv4.ProjectV2FieldValue{
			IterationID: githubv4.NewString(githubv4.String(config.opts.iterationID)),
		}
	}

	return &UpdateProjectV2FieldValue{}, map[string]interface{}{
		"input": githubv4.UpdateProjectV2ItemFieldValueInput{
			ProjectID: githubv4.ID(config.opts.projectID),
			ItemID:    githubv4.ID(config.opts.itemID),
			FieldID:   githubv4.ID(config.opts.fieldID),
			Value:     value,
		},
	}