Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350422 - [commit][status] Specify the committer and author names/mails per commit
Summary: [commit][status] Specify the committer and author names/mails per commit
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Git (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 0.3 M1   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard: gsoc2011
Keywords:
: 351442 (view as bug list)
Depends on:
Blocks: 351458 353120
  Show dependency tree
 
Reported: 2011-06-27 06:32 EDT by Szymon Brandys CLA
Modified: 2012-01-19 11:45 EST (History)
2 users (show)

See Also:
tomasz.zarna: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Brandys CLA 2011-06-27 06:32:25 EDT
We should be able to specify the committer and author names/mails for a commit.
Comment 1 Szymon Brandys CLA 2011-07-07 09:06:12 EDT
*** Bug 351442 has been marked as a duplicate of this bug. ***
Comment 2 Piotr Janik CLA 2011-07-14 09:43:05 EDT
Fix:
https://github.com/pjanik/orion.client/tree/bug350422
https://github.com/pjanik/orion.server/tree/bug350422

I wrote all this code and have the rights to contribute it to Eclipse under the
eclipse.org web site terms of use.
Comment 3 Tomasz Zarna CLA 2011-07-20 11:31:04 EDT
See my comments regarding server side here: https://github.com/pjanik/orion.server/commit/ec6ae9b31ab56ce0141298a6eaaa1cc1b1ddf5fa
Comment 4 Piotr Janik CLA 2011-07-21 05:56:36 EDT
(In reply to comment #3)
> See my comments regarding server side here:
> https://github.com/pjanik/orion.server/commit/ec6ae9b31ab56ce0141298a6eaaa1cc1b1ddf5fa

Fixed: https://github.com/pjanik/orion.server/tree/bug350422
Comment 5 Tomasz Zarna CLA 2011-07-21 15:29:06 EDT
Let's start from the server side, I have bad feelings about these lines:

String committerName = requestObject.optString(GitConstants.KEY_COMMITTER_NAME, "");
...
if (!committerName.isEmpty() || !committerEmail.isEmpty())
 commit.setCommitter(committerName, committerEmail);

I would rather see those values defaulted to null and passed like that to the CommitCommand. According the its javadoc a null value should result in a fallback. However, after running a simple test for the command it turned out it doesn't seem to work as documented, if that's the case then we should file about a bug for JGit saying their API is not precise.

Tests: You haven't touched the part in GitCommitTest#getPostGitCommitRequest where extra params for committer/author are added to the body. I would add null checks there.

As for the UI part, I think we all agree that the Git Status page is already cluttered. Putting 4 more text fields there is not an option. They should be hidden in an expandable widget (a div?) and only visible on special occasion - when user decides to change them. Moreover, these fields could be pre-populated with default values. I guess EGit does a similar thing in its Commit dialog.

Last but not least, are you able to set name or email to "" (empty string) with the proposed UI/server side logic? It's not crucial, but a valid scenario in git bash.
Comment 6 Piotr Janik CLA 2011-07-22 16:42:15 EDT
New version:
https://github.com/pjanik/orion.client/tree/bug350422
https://github.com/pjanik/orion.server/tree/bug350422
(In reply to comment #5)
> Let's start from the server side, I have bad feelings about these lines:
> 
> String committerName = requestObject.optString(GitConstants.KEY_COMMITTER_NAME,
> "");
> ...
> if (!committerName.isEmpty() || !committerEmail.isEmpty())
>  commit.setCommitter(committerName, committerEmail);
> 
> I would rather see those values defaulted to null and passed like that to the
> CommitCommand. According the its javadoc a null value should result in a
> fallback. However, after running a simple test for the command it turned out it
> doesn't seem to work as documented, if that's the case then we should file
> about a bug for JGit saying their API is not precise.
Yes, null support is broken/different from javadoc, so it was the cause of that approach. But I agree that it could be done better. Now GitCommitHandlerV1 handles null values itself, so it's workaround for the mentioned JGit bug.

> Tests: You haven't touched the part in GitCommitTest#getPostGitCommitRequest
> where extra params for committer/author are added to the body. I would add null
> checks there.
JSONObject.put(...) javadoc:
"Put a key/value pair in the JSONObject. If the value is null, then the key will be removed from the JSONObject if it is present." So, I omit null checks, as null values won't be inserted anyway. 

> As for the UI part, I think we all agree that the Git Status page is already
> cluttered. Putting 4 more text fields there is not an option. They should be
> hidden in an expandable widget (a div?) and only visible on special occasion -
> when user decides to change them. Moreover, these fields could be pre-populated
> with default values. I guess EGit does a similar thing in its Commit dialog.
Done. Inputs are hidden by default. There is a command, which shows them. They are pre-populated with default values.

> Last but not least, are you able to set name or email to "" (empty string) with
> the proposed UI/server side logic? It's not crucial, but a valid scenario in
> git bash.
Yes, now you are able to set name/email to "".
Comment 7 Tomasz Zarna CLA 2011-07-25 04:58:55 EDT
(In reply to comment #6)
> > According the its javadoc a null value should result in a
> > fallback. However, after running a simple test for the command it turned out
> > it doesn't seem to work as documented, if that's the case then we should file
> > about a bug for JGit saying their API is not precise.
> Yes, null support is broken/different from javadoc, so it was the cause of that
> approach. But I agree that it could be done better. Now GitCommitHandlerV1
> handles null values itself, so it's workaround for the mentioned JGit bug.

Have you filed a bug against JGit?
Comment 8 Piotr Janik CLA 2011-07-25 05:31:21 EDT
JGit bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352984
Comment 9 Tomasz Zarna CLA 2011-07-25 06:32:52 EDT
(In reply to comment #6)

> Done. Inputs are hidden by default. There is a command, which shows them. They
> are pre-populated with default values.

Being able to show hidden fields is great, but I would like to be able to hide them again, when not needed. Just like on Repositories page when you want to clone a repo and you're picking target location: Choose target location / Default target location.

Also, the default values are not accurate. Go to Profile page, change values for Git mail and Git name and clone a repo. Or just change these values for an existing repository. When you then go the Status page you will see that suggested values for committer and author are not those you would expect. They should be taken from the repo configuration or user profile.

Finally, I would place label and both fields in a single line, so they take less space. Something like this would work, imo "Committer name: [...] mail: [...]".

I'm fine with the server side changes, thanks for the update.
Comment 10 Piotr Janik CLA 2011-07-25 10:19:46 EDT
> Being able to show hidden fields is great, but I would like to be able to hide
> them again, when not needed. Just like on Repositories page when you want to
> clone a repo and you're picking target location: Choose target location /
> Default target location.
Done.
> Also, the default values are not accurate. Go to Profile page, change values
> for Git mail and Git name and clone a repo. Or just change these values for an
> existing repository. When you then go the Status page you will see that
> suggested values for committer and author are not those you would expect. They
> should be taken from the repo configuration or user profile.
Default values are taken from the repo configuration.
> Finally, I would place label and both fields in a single line, so they take
> less space. Something like this would work, imo "Committer name: [...] mail:
> [...]".
Done.