Does the since query work for commits in Stash?

The following two REST queries return me exactly the same 25 commits:

https://stash.corp.netflix.com/rest/api/1.0/projects/ENGTOOLS/repos/odin/commits/?since=62c9682669b6f594ebfd3a362c8692d0a95b2168

https://stash.corp.netflix.com/rest/api/1.0/projects/ENGTOOLS/repos/odin/commits

Since 62c96826 is the sixth commit returned by the first query I would expect the second query to return me only five (or six?) commits, the five that have been committed "since" 62c96826. Do misunderstand how this works.

1 answer

1 accepted

Hi Curt,

I'm afraid that particular endpoint seems to require that if you want to use 'since' you must provide _both_ since and until. I'm not entirely sure if this is by design or not. The REST documentation does somewhat indicate this, but that may just be based on the current behaviour.

Retrieve a page of changesets from a given starting commit or between two commits.

EDIT: Actually now that I think about it, the reason would have to be that without the 'until' parameter we wouldn't know what branch (or changeset) to terminate at. Would you mean the default branch, which is what happens without any params? I will definitely ask someone next week though.

Cheers,

Charles

First, Charles, thanks for the clarification. That works just fine, and will meet my needs.

I do think that the doc should be updated:

- My prefernece is for the behavior to change. Since there is default behavior for no-parameters, I think it is fair to expect the same behavior with since only.

- No-parameters is neither "a given starting point or between two commits". Since that is not true, it seems very natural to assume, in the absence of specific documentation, that the "since" only should work even though not technically meeting the same test. :-)

- The descriptions for 'since' and 'until' are almost identical even though one flies solo just fine and the other doesn't. That difference in behavior should be called out explicitly in the docs.

Charles,

This is a bit of a side note, but maybe worth mentioning while we are talking about documentation:

The https://developer.atlassian.com/stash/docs/latest/how-tos/command-line-rest.html page gives an example which doesn't seem to work as I'd expect if I change the 'at' parameter, and I don't see that parameter documented anywhere. I'm guessing it isn't valid?:

curl -u fred:fred -X POST -H "Content-Type: application/json" http://localhost:7990/rest/api/1.0/projects/WORK/repos/my-repo/commits/?at=master

Hi Curt,

Thanks for pointing that out. In the code that's marked as 'deprecated' (but for some reason isn't being generated in the docs) and has been replaced completely by 'until'. I'll make sure we update that example too.

Cheers,

Charles

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

135 views 17 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you