Repository: dolthub/dolt
File: go/libraries/doltcore/sqle/dprocedures/dolt_commit.go (Go)

Code before:
		Name:             name,
		Email:            email,
		SkipVerification: apr.Contains(cli.SkipVerificationFlag),
	}

	shouldSign, err := dsess.GetBooleanSystemVar(ctx, "gpgsign")
	if err != nil {
		return "", false, fmt.Errorf("failed to get gpgsign: %w", err)
	}

	pendingCommit, err := dSess.NewPendingCommit(ctx, dbName, roots, csp)
	if err != nil {
		return "", false, err
	}

	// we've checked for the presence of --allow-empty and --skip-empty previously, and verified they don't coexist.
	if pendingCommit == nil && !apr.Contains(cli.AllowEmptyFlag) {
		// Nothing to commit. Finalize the transaction if there is one. There could be ignored tables, and we want
		// to avoid leaving transactions open since dolt_commit is expected to COMMIT.
		err = dSess.CommitTransaction(ctx, dSess.GetTransaction())
		if err != nil {
			return "", false, err
		}

		if apr.Contains(cli.SkipEmptyFlag) {
			return "", true, err
		}
		return "", false, errors.New("nothing to commit")
	}

	if apr.Contains(cli.SignFlag) || shouldSign {
		keyId := apr.GetValueOrDefault(cli.SignFlag, "")

		if keyId == "" {
			v, err := ctx.GetSessionVariable(ctx, "signingkey")
			if err != nil && !sql.ErrUnknownSystemVariable.Is(err) {
				return "", false, fmt.Errorf("failed to get signingkey: %w", err)
			} else if err == nil {
				keyId = v.(string)
			}
		}

		strToSign, err := commitSignatureStr(ctx, dbName, roots, csp)
		if err != nil {
			return "", false, err
		}

		signature, err := gpg.Sign(ctx, keyId, []byte(strToSign))
		if err != nil {
			return "", false, err
		}

Review comment (suggestion):
(minor) Seems like `err` would always be empty at this point, but might be clearer to explicitly use `nil` instead of `err`.

```suggestion
			return "", true, nil
```

Code after:
		Name:             name,
		Email:            email,
		SkipVerification: apr.Contains(cli.SkipVerificationFlag),
	}

	shouldSign, err := dsess.GetBooleanSystemVar(ctx, "gpgsign")
	if err != nil {
		return "", false, fmt.Errorf("failed to get gpgsign: %w", err)
	}

	pendingCommit, err := dSess.NewPendingCommit(ctx, dbName, roots, csp)
	if err != nil {
		return "", false, err
	}

	// we've checked for the presence of --allow-empty and --skip-empty previously, and verified they don't coexist.
	if pendingCommit == nil && !apr.Contains(cli.AllowEmptyFlag) {
		// Nothing to commit. Finalize the transaction if there is one. There could be ignored tables, and we want
		// to avoid leaving transactions open since dolt_commit is expected to COMMIT.
		err = dSess.CommitTransaction(ctx, dSess.GetTransaction())
		if err != nil {
			return "", false, err
		}

		if apr.Contains(cli.SkipEmptyFlag) {
			return "", true, nil
		}
		return "", false, errors.New("nothing to commit")
	}

	if apr.Contains(cli.SignFlag) || shouldSign {
		keyId := apr.GetValueOrDefault(cli.SignFlag, "")

		if keyId == "" {
			v, err := ctx.GetSessionVariable(ctx, "signingkey")
			if err != nil && !sql.ErrUnknownSystemVariable.Is(err) {
				return "", false, fmt.Errorf("failed to get signingkey: %w", err)
			} else if err == nil {
				keyId = v.(string)
			}
		}

		strToSign, err := commitSignatureStr(ctx, dbName, roots, csp)
		if err != nil {
			return "", false, err
		}

		signature, err := gpg.Sign(ctx, keyId, []byte(strToSign))
		if err != nil {
			return "", false, err
		}