Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 346285

Summary: [server][tag] Tagging with a tag name that already exist should not throw 500 error
Product: [ECD] Orion Reporter: Tomasz Zarna <tomasz.zarna>
Component: GitAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: janikpiotrek, Szymon.Brandys
Version: 0.2Flags: tomasz.zarna: review+
Target Milestone: 0.3 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard: gsoc2011

Description Tomasz Zarna CLA 2011-05-18 11:28:28 EDT
Tagging with a tag name that already exists should not end up with an Internal Server Error. It should not matter if you tried to tag a commit that already had been tagged with the tag or you tried to tag a different commit (move a tag?).
Comment 1 Piotr Janik CLA 2011-07-26 14:28:40 EDT
https://github.com/pjanik/orion.server/tree/bug346285

I wrote all this code and have the rights to contribute it to Eclipse under the
eclipse.org web site terms of use.

Forced update solves all the problems. 500 is not thrown and it also moves a tag when it's needed.
Comment 2 Tomasz Zarna CLA 2011-07-27 06:28:26 EDT
Nice try, but this is not what we want ;) When tagging the user will not be aware that he's replacing an existing tag. Moreover, he needs to refresh the page to figure out which commit he has just tagged. What we need here is a user friendly message saying why tagging failed. 

This makes this bug somehow similar to bug 353135.
Comment 3 Piotr Janik CLA 2011-07-27 06:31:03 EDT
So, do you want to move tag or return error message?
I can see some inconsistency. ;)
Comment 4 Tomasz Zarna CLA 2011-07-27 06:48:37 EDT
When did I say I want to move the tag? What I meant in comment 0 is that both actions (tagging a commit with a tag which was already used to on that commit and tagging a different commit with an existing tag) should have the same output. An output different than 500.
Comment 5 Piotr Janik CLA 2011-07-27 07:27:58 EDT
Updated.
https://github.com/pjanik/orion.server/tree/bug346285
https://github.com/pjanik/orion.client/tree/bug346285

500 is still thrown as this action causes JGitInternalException and I cannot distinguish a cause (i.e. that tag already exist etc.). It's JGit specific problem.

I've added in client showing error on the status panel. Now, detailed message from JGit is show (it isn't beautiful). Other option is to show just "An error occured when tagging.", but we can miss some useful information in other error case, when JGitInternalException is thrown and detailed message is more descriptive.
Comment 6 Tomasz Zarna CLA 2011-07-27 10:31:37 EDT
Do we have a test case covering this? Also, once you've modified GitCommitHandlerV1.tag(HttpServletRequest, HttpServletResponse, Repository, String, String, boolean) I think you should do the same with GitTagHandlerV1.handlePost(HttpServletRequest, HttpServletResponse, String) even though it's not called by the client. Test cases for both ways of tagging would be required to make sure they both fail in the same manner.
Comment 7 Tomasz Zarna CLA 2011-07-27 10:34:11 EDT
(In reply to comment #6)
> GitCommitHandlerV1.tag(HttpServletRequest, HttpServletResponse, Repository, String, String, boolean) 

btw, the signature can be cleaned up in terms of thrown exceptions.
Comment 8 Piotr Janik CLA 2011-07-29 07:41:00 EDT
Fixed, test added.