Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stash REST API gives ambiguous errors when handling DELETE requests
If the stash is not empty, a DELETE request without any stash
revisions should drop the entire stash.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
  • Loading branch information
rcjsuen committed Jun 1, 2017
1 parent 2cee303 commit e3c979f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/orionode/lib/git/stash.js
Expand Up @@ -122,7 +122,7 @@ function deleteStash(req, res) {
index = i;
}
} else {
all.push(git.Stash.drop(repo, index));
all.push(git.Stash.drop(repo, i));
}
})
.then(function() {
Expand Down
32 changes: 32 additions & 0 deletions modules/orionode/test/test-git-api.js
Expand Up @@ -489,6 +489,10 @@ GitClient.prototype = {
statusCode = 200;
}

if (revision === undefined) {
revision = "";
}

var client = this;
this.tasks.push(function(resolve) {
request()
Expand Down Expand Up @@ -3916,7 +3920,35 @@ maybeDescribe("git", function() {
client.setFileContents(file, "abcx");
client.stash();
client.stashDrop("rev123", 400, "Invalid stash reference rev123.");
client.listStash();
client.start().then(function(body) {
assert.equal(body.Children.length, 1);
finished();
})
.catch(function(err) {
finished(err);
});
}); // it("invalid stash rev")"

/**
* Stash something and then ask Orion to drop the entire stash.
*/
it("all", function(finished) {
var file = "a.txt";
var client = new GitClient("stash-drop-all");
client.init();
// track this file
client.setFileContents(file, "abc");
client.stage(file);
client.commit();

// modify the file
client.setFileContents(file, "abcx");
client.stash();
client.stashDrop();
client.listStash();
client.start().then(function(body) {
assert.equal(body.Children.length, 0);
finished();
})
.catch(function(err) {
Expand Down

0 comments on commit e3c979f

Please sign in to comment.