diff --git a/ChangeLog.txt b/ChangeLog.txt index 1c63218b4e..e48071778c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,11 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-03-18 00:09 UTC+0100 Viktor Szakats (harbour syenar.net) + * bin/commit.hb + + automatically use the git username and e-mail in the + generated ChangeLog.txt entries + 2013-03-18 00:01 UTC+0100 Viktor Szakats (harbour syenar.net) * doc/howtorep.txt * updated for Git diff --git a/bin/commit.hb b/bin/commit.hb index 21b8cfbb9c..4a89a984f3 100644 --- a/bin/commit.hb +++ b/bin/commit.hb @@ -51,12 +51,16 @@ PROCEDURE Main() // ; - IF ! Empty( GetEnv( _CONFIGENV_ ) ) - cMyName := GetEnv( _CONFIGENV_ ) - ELSEIF hb_FileExists( _CONFIGFIL_ ) - cMyName := AllTrim( hb_MemoRead( _CONFIGFIL_ ) ) + IF cVCS == "git" + cMyName := GitUser() ELSE - cMyName := "Firstname Lastname (me domain.net)" + IF ! Empty( GetEnv( _CONFIGENV_ ) ) + cMyName := GetEnv( _CONFIGENV_ ) + ELSEIF hb_FileExists( _CONFIGFIL_ ) + cMyName := AllTrim( hb_MemoRead( _CONFIGFIL_ ) ) + ELSE + cMyName := "Firstname Lastname (me domain.net)" + ENDIF ENDIF nOffset := hb_UTCOffset() @@ -223,3 +227,15 @@ STATIC FUNCTION Changes( cVCS ) ENDCASE RETURN hb_ATokens( StrTran( cStdOut, Chr( 13 ) ), Chr( 10 ) ) + +STATIC FUNCTION GitUser() + + LOCAL cName := "" + LOCAL cEMail := "" + + hb_processRun( Shell() + " " + CmdEscape( "git config user.name" ),, @cName ) + hb_processRun( Shell() + " " + CmdEscape( "git config user.email" ),, @cEMail ) + + RETURN hb_StrFormat( "%s (%s)", ; + AllTrim( hb_StrReplace( cName, Chr( 10 ) + Chr( 13 ), "" ) ), ; + StrTran( AllTrim( hb_StrReplace( cEMail, Chr( 10 ) + Chr( 13 ), "" ) ), "@", " " ) )