markmssd/bitbucket-server-nodejs

`client.repos.getAll` compounds results of previous calls

adrukh opened this issue · 2 comments

The implementation of client.repos.getAll is not idempotent, and compounds responses from the second call onwards.
It seems to keep a global state of all repos read (for recursion purposes), requiring the creation of a new client to nullify state.

The culprit is at https://github.com/markmssd/bitbucket-server-nodejs/blob/master/lib/api/repos.js#L10

The following code demonstrates the issue:

const client = new Client(url, auth);

client.repos.getAll().then(repos => console.log(repos.length)); // prints N
client.repos.getAll().then(repos => console.log(repos.length)); // prints 2N

Can you please comment on this finding? I can submit a quick PR that will add an optional repos array as a second arg of getAll, allowing the recursion to carry its state internally.

Hey! Sorry for this delayed response and thanks for pointing out this issue.

I have tried it and I can confirm this issue. If you're still willing to submit your PR I would greatly appreciate it!

Thanks :)

@adrukh I have fixed this issue here: 4ff4477

Thanks for pointing it out!