Search code examples
gitdategit-commitbitbucket-server

Get git commit info by dates with stash rest api


Is there a way to get git commits info by dates with stash rest API?

I have searched developer documentation, and learned that you could get commits info with commit id and so on, but not with date.

https://developer.atlassian.com/stash/docs/latest/reference/rest-api.html


Solution

  • As per the reference document for the Atlassian Stash REST API.

    /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits 
    

    can be used to retrieve a page of changesets from a given starting commit or between two commits. The commits may be identified by branch or tag name or by hash. A path may be supplied to restrict the returned changesets to only those which affect that path

    Sample response

    {
        "size": 1,
        "limit": 25,
        "isLastPage": true,
        "values": [
            {
                "id": "def0123abcdef4567abcdef8987abcdef6543abc",
                "displayId": "def0123",
                "author": {
                    "name": "charlie",
                    "emailAddress": "charlie@example.com"
                },
                "authorTimestamp": 1377738985925,
                "message": "More work on feature 1",
                "parents": [
                    {
                        "id": "abcdef0123abcdef4567abcdef8987abcdef6543",
                        "displayId": "abcdef0"
                    }
                ]
            }
        ],
        "start": 0,
        "filter": null,
        "authorCount": 1,
        "totalCount": 1
    }
    

    You could use authorTimestamp to achieve your goal.