@@ -351,9 +351,12 @@ ClassMethod Commit(InternalName As %String, Message As %String = "example commit
351351 set filename = ..FullExternalName (.InternalName )
352352 set username = ..GitUserName ()
353353 set email = ..GitUserEmail ()
354- set author = username _" <" _email _" >"
354+ set author = " "
355+ if ((username '= " " ) && (email '= " " )) {
356+ set author = username _" <" _email _" >"
357+ }
355358 do ..RunGitWithArgs (.errStream , .outStream , " commit" , " --author" , author , " -m" , Message , filename )
356- do ..PrintStreams (outStream , outStream )
359+ do ..PrintStreams (errStream , outStream )
357360 $$$QuitOnError(##class (SourceControl.Git.Change ).RemoveUncommitted (filename ))
358361 $$$QuitOnError(##class (SourceControl.Git.Change ).RefreshUncommitted (,,,1 ))
359362 quit $$$OK
@@ -397,7 +400,10 @@ ClassMethod SyncCommit(Msg As %String) As %Status
397400 set uncommittedFilesWithAction = ##class (SourceControl.Git.Utils ).UncommittedWithAction ().%Get (" user" )
398401 set username = ..GitUserName ()
399402 set email = ..GitUserEmail ()
400- set author = username _" <" _email _" >"
403+ set author = " "
404+ if ((username '= " " ) && (email '= " " )) {
405+ set author = username _" <" _email _" >"
406+ }
401407 do ..RunGitWithArgs (.errStream , .outStream , " commit" , " --author" , author , " -m" , Msg )
402408 do ..PrintStreams (errStream , outStream )
403409 $$$QuitOnError(..ClearUncommitted (uncommittedFilesWithAction ))
@@ -1672,8 +1678,13 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
16721678 set newArgs ($increment (newArgs )) = " core.sshCommand=ssh -F /dev/null -o StrictHostKeyChecking=accept-new -i " _privateKeyFile
16731679 }
16741680
1675- set username = ..GitUserName ()
1676- set email = ..GitUserEmail ()
1681+ set username = " "
1682+ set email = " "
1683+
1684+ if (..GitUserName () '= " " ) && (..GitUserEmail () '= " " ) {
1685+ set username = ..GitUserName ()
1686+ set email = ..GitUserEmail ()
1687+ }
16771688
16781689 set newArgs ($increment (newArgs )) = " -c"
16791690 set newArgs ($increment (newArgs )) = " user.name=" _username
@@ -1689,6 +1700,7 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
16891700 set diffCompare = " "
16901701 set invert = 0
16911702 set whichStash = " "
1703+ set isCommit = 0
16921704
16931705 // Find / build file list
16941706 set hasFileList = 0
@@ -1735,6 +1747,8 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
17351747 set syncIrisWithDiff = 1
17361748 set diffCompare = whichStash
17371749 }
1750+ } elseif (command = " commit" ) {
1751+ set isCommit = 1
17381752 }
17391753
17401754 // WebUI prefixes with "color.ui=true" so we need to grab the command
@@ -1770,6 +1784,8 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
17701784 } elseif (args (i ) = " merge" ) || (args (i ) = " rebase" ) || (args (i ) = " pull" ) {
17711785 set syncIrisWithCommand = 1
17721786 set diffCompare = args (i + 1 )
1787+ } elseif (args (i ) = " commit" ) {
1788+ set isCommit = 1
17731789 }
17741790 }
17751791 }
@@ -1813,6 +1829,15 @@ ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", O
18131829 set errStream = ##class (%Stream.FileCharacter ).%OpenId (errLog ,,.sc )
18141830 set outStream = ##class (%Stream.FileCharacter ).%OpenId (outLog ,,.sc )
18151831 set outStream .TranslateTable =" UTF8"
1832+
1833+ if ((isCommit ) && (returnCode = 128 )){
1834+ set errStreamLine = errStream .ReadLine ()
1835+ if (((errStreamLine = " Committer identity unknown" ) || (errStreamLine = " Author identity unknown" ))) {
1836+ do errStream .Clear ()
1837+ do errStream .WriteLine (" Commit failed as user identity unknown." _$c (13 ,10 )_$c (13 ,10 )_" Go to the Settings page in the Source Control menu to fix this." _$c (13 ,10 ))
1838+ }
1839+ }
1840+
18161841 for stream =errStream ,outStream {
18171842 set stream .RemoveOnClose = 1
18181843 }
0 commit comments