Skip to content

Conversation

mstv
Copy link
Member

@mstv mstv commented Nov 18, 2023

Fixes #11366
Fixes #11368

Proposed changes

  • Let git deny the commit if committer is not specified
    • Let GetEffectiveGitSetting return null if the setting is not set
    • Remove FormCommit.OnActivated in order to avoid repeated exception popups from the only called function UpdateAuthorInfo

Screenshots

Before

Exception (repeated exceptions unless quickly repeating Esc)

After

image

Test methodology

  • manual
  • adapt affected testcase

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@mstv mstv self-assigned this Nov 18, 2023
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1

@@ -2713,14 +2713,29 @@ private void UpdateAuthorInfo()
ThreadHelper.FileAndForget(async () =>
{
// Do not cache results in order to update the info on FormActivate
string userName = Module.GetEffectiveGitSetting(SettingKeyString.UserName, cache: false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not try-catch if the reason is known - in this case git-log return 0 is OK
This is the part of #11146 I approved (the rest of the discussion there just got me loose motivation for GE and a dev in general though).

Could be an option to GetEffectiveGitSetting, but this is currently the only caller.

It is also not necessary to call UpdateAuthorInfo() in OnActivate.

0001-Do-not-throw-for-git-log-no-key-exists.patch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch. I did not think of its availability when I decided to not touch the ExecutableExtensions.GetOutput() chain.

It is also not necessary to call UpdateAuthorInfo() in OnActivate.

The setting could be changed using another app (instance).
But removing OnActivate was the easiest way to get rid of repeated exception popups.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the status bar. On activate is on purpose so that the commiter and author info is updated when user activates window because git config could have been executed. It is to make sure user sees up to date info.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to make sure user sees up to date info.

As said it is not worth it. If users use another app / instance for changing the settings, they can reopen FormCommit if they wonder whether the settings are in effect or not. That's not that unusual.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @mstv, it's not worth it.

Comment on lines 2706 to 2707
string userName = Module.GetEffectiveGitSetting(SettingKeyString.UserName, cache: false) ?? "USER NOT CONFIGURED";
string userEmail = Module.GetEffectiveGitSetting(SettingKeyString.UserEmail, cache: false) ?? "E-MAIL NOT CONFIGURED";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the screaming strings. Maybe something like this?

Suggested change
string userName = Module.GetEffectiveGitSetting(SettingKeyString.UserName, cache: false) ?? "USER NOT CONFIGURED";
string userEmail = Module.GetEffectiveGitSetting(SettingKeyString.UserEmail, cache: false) ?? "E-MAIL NOT CONFIGURED";
string userName = Module.GetEffectiveGitSetting(SettingKeyString.UserName, cache: false) ?? "<username not configured>";
string userEmail = Module.GetEffectiveGitSetting(SettingKeyString.UserEmail, cache: false) ?? "<email not configured>";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed, but using "/" instead of "<>" which occurs in the e-mail address.

@mstv mstv merged commit 44be238 into gitextensions:master Nov 20, 2023
@ghost ghost added this to the vNext milestone Nov 20, 2023
@mstv mstv deleted the fix/i11366_committer_info branch November 20, 2023 22:59
@RussKie
Copy link
Member

RussKie commented Nov 23, 2023

Backport to release/4.0?

mstv added a commit that referenced this pull request Nov 23, 2023
- Return null if git config setting is not set and display "/... not configured/"
- Remove FormCommit.OnActivated in order to avoid repeated exception popups

Co-authored-by: Jay Asbury <vbjay@users.noreply.github.com>
Co-authored-by: Gerhard Olsson <gerhardol@users.noreply.github.com>
(cherry picked from commit 44be238)
@mstv mstv modified the milestones: vNext, 4.2.1 Nov 23, 2023
@mstv
Copy link
Member Author

mstv commented Nov 23, 2023

Backport to release/4.0?

done

@RussKie
Copy link
Member

RussKie commented Nov 23, 2023

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants