Skip to content

Contents POST APIs result in nil commit dates #35860

@divyun

Description

@divyun

Description

Calling the following endpoint, without the "dates" field, results in commit and author dates set to 2001-01-01T00:00:00Z. Look at the update date for some_image.png @ https://demo.gitea.com/divyun/contents_api_date_test

POST /api/v1/repos/divyun/contents_api_date_test/contents HTTP/1.1
Content-Length: 289
Content-Type: application/json
Host: demo.gitea.com
User-Agent: HTTPie

{
  "files": [
    {
      "path": "some_image.png",
      "operation": "create",
      "content": "dmVyc2lvbiBodHRwczovL2dpdC1sZnMuZ2l0aHViLmNvbS9zcGVjL3YxCm9pZCBzaGEyNTY6OGFlZGI0MjhjYmI4MTVkZmZlYTY1MGZlNzViZmYwMzJlYTI0MGYwMGNjYWQyZjY0ZGM4ZjYyYTBjNWUzMDMxMwpzaXplIDE2MzAyCg=="
    }
  ]
}
{
  "files": [
    {
      "name": "some_image.png",
      "path": "some_image.png",
      "sha": "d2c20c45d17d75d8f3a4a14c0fab278bc1d71720",
      "last_commit_sha": "8126020266cf3e6634acbff50c54417df5e24ce8",
      "last_committer_date": "2001-01-01T00:00:00Z",
      "last_author_date": "2001-01-01T00:00:00Z",
      "type": "file",
      "size": 130,
      "encoding": "base64",
      "content": "dmVyc2lvbiBodHRwczovL2dpdC1sZnMuZ2l0aHViLmNvbS9zcGVjL3YxCm9pZCBzaGEyNTY6OGFlZGI0MjhjYmI4MTVkZmZlYTY1MGZlNzViZmYwMzJlYTI0MGYwMGNjYWQyZjY0ZGM4ZjYyYTBjNWUzMDMxMwpzaXplIDE2MzAyCg==",
      "target": null,
      "url": "https://demo.gitea.com/api/v1/repos/divyun/contents_api_date_test/contents/some_image.png?ref=main",
      "html_url": "https://demo.gitea.com/divyun/contents_api_date_test/src/branch/main/some_image.png",
      "git_url": "https://demo.gitea.com/api/v1/repos/divyun/contents_api_date_test/git/blobs/d2c20c45d17d75d8f3a4a14c0fab278bc1d71720",
      "download_url": "https://demo.gitea.com/divyun/contents_api_date_test/raw/branch/main/some_image.png",
      "submodule_git_url": null,
      "_links": {
        "self": "https://demo.gitea.com/api/v1/repos/divyun/contents_api_date_test/contents/some_image.png?ref=main",
        "git": "https://demo.gitea.com/api/v1/repos/divyun/contents_api_date_test/git/blobs/d2c20c45d17d75d8f3a4a14c0fab278bc1d71720",
        "html": "https://demo.gitea.com/divyun/contents_api_date_test/src/branch/main/some_image.png"
      },
      "lfs_oid": "8aedb428cbb815dffea650fe75bff032ea240f00ccad2f64dc8f62a0c5e30313",
      "lfs_size": 16302
    }
  ],
  "commit": {
    "url": "https://demo.gitea.com/api/v1/repos/divyun/contents_api_date_test/git/commits/8126020266cf3e6634acbff50c54417df5e24ce8",
    "sha": "8126020266cf3e6634acbff50c54417df5e24ce8",
    "created": "0001-01-01T00:00:00Z",
    "html_url": "https://demo.gitea.com/divyun/contents_api_date_test/commit/8126020266cf3e6634acbff50c54417df5e24ce8",
    "author": {
      "name": "divyun",
      "email": "divyun@noreply.localhost",
      "date": "2001-01-01T00:00:00Z"
    },
    "committer": {
      "name": "divyun",
      "email": "divyun@noreply.localhost",
      "date": "2001-01-01T00:00:00Z"
    },
    "parents": [],
    "message": "Add some_image.png\n",
    "tree": {
      "url": "https://demo.gitea.com/api/v1/repos/divyun/contents_api_date_test/git/trees/116c20e75c5d820e785a640e2787a32a019059c0",
      "sha": "116c20e75c5d820e785a640e2787a32a019059c0",
      "created": "0001-01-01T00:00:00Z"
    }
  },
  "verification": {
    "verified": false,
    "reason": "gpg.error.not_signed_commit",
    "signature": "",
    "signer": null,
    "payload": ""
  }
}

Gitea Version

1.25.1

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Have verified it gitea demo site, with the latest docker image and the main source branch locally.

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions