Skip to content

Commit

Permalink
added optional allow empty commits (#7186)
Browse files Browse the repository at this point in the history
* added optional allow empty commits
  • Loading branch information
lynnro314 authored Jan 3, 2024
1 parent fd2a2d5 commit 88247ac
Show file tree
Hide file tree
Showing 29 changed files with 173 additions and 60 deletions.
4 changes: 4 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ components:
description: set date to override creation date in the commit (Unix Epoch in seconds)
type: integer
format: int64
allow_empty:
description: sets whether a commit can contain no changes
type: boolean
default: false
force:
type: boolean
default: false
Expand Down
5 changes: 5 additions & 0 deletions clients/java-legacy/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/java-legacy/docs/CommitCreation.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions clients/java/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/java/docs/CommitCreation.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python-legacy/docs/CommitCreation.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python-legacy/docs/CommitsApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python-legacy/docs/ImportApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions clients/python-legacy/lakefs_client/model/commit_creation.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python/docs/CommitCreation.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion clients/python/lakefs_sdk/models/commit_creation.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python/test/test_commit_creation.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions clients/python/test/test_import_creation.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions cmd/lakectl/cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var errInvalidKeyValueFormat = errors.New(`invalid key/value pair - should be se

const (
dateFlagName = "epoch-time-seconds"
allowEmptyCommit = "allow-empty-commit"
commitCreateTemplate = `Commit for branch "{{.Branch.Ref}}" completed.
ID: {{.Commit.Id|yellow}}
Expand All @@ -32,6 +33,7 @@ var commitCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
message, kvPairs := getCommitFlags(cmd)
date := Must(cmd.Flags().GetInt64(dateFlagName))
emptyCommitBool := Must(cmd.Flags().GetBool(allowEmptyCommit))
datePtr := &date
if date < 0 {
datePtr = nil
Expand All @@ -46,9 +48,10 @@ var commitCmd = &cobra.Command{
}
client := getClient()
resp, err := client.CommitWithResponse(cmd.Context(), branchURI.Repository, branchURI.Ref, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{
Message: message,
Metadata: &metadata,
Date: datePtr,
Message: message,
Metadata: &metadata,
Date: datePtr,
AllowEmpty: &emptyCommitBool,
})
DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusCreated)
if resp.JSON201 == nil {
Expand All @@ -66,6 +69,7 @@ var commitCmd = &cobra.Command{
//nolint:gochecknoinits
func init() {
commitCmd.Flags().Int64(dateFlagName, -1, "create commit with a custom unix epoch date in seconds")
commitCmd.Flags().Bool(allowEmptyCommit, false, "allow a commit with no changes")
if err := commitCmd.Flags().MarkHidden(dateFlagName); err != nil {
DieErr(err)
}
Expand Down
4 changes: 4 additions & 0 deletions docs/assets/js/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ components:
description: set date to override creation date in the commit (Unix Epoch in seconds)
type: integer
format: int64
allow_empty:
description: sets whether a commit can contain no changes
type: boolean
default: false
force:
type: boolean
default: false
Expand Down
1 change: 1 addition & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ lakectl commit <branch URI> [flags]
{:.no_toc}

```
--allow-empty-commit allow a commit with no changes
--allow-empty-message allow an empty commit message
-h, --help help for commit
-m, --message string commit message
Expand Down
Loading

0 comments on commit 88247ac

Please sign in to comment.