From 9eb5f5b7bbb34e2209b6ba6d24fc465ec971538b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 Apr 2013 18:59:41 +0200 Subject: [PATCH] 2013-04-08 18:53 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnetio/tests/netiotst.prg * minor fmt --- ChangeLog.txt | 4 +++ bin/commit.hb | 40 ++++++++++++++++++++++-------- contrib/hbnetio/tests/netiotst.prg | 2 +- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index aa75b7c3fb..a035c0285c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,10 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-04-08 18:53 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbnetio/tests/netiotst.prg + * minor fmt + 2013-04-08 14:57 UTC+0200 Viktor Szakats (harbour syenar.net) * commit.hb + made it work regardless of cwd diff --git a/bin/commit.hb b/bin/commit.hb index bf0214b362..3ac10e3491 100644 --- a/bin/commit.hb +++ b/bin/commit.hb @@ -34,20 +34,29 @@ #define _COMMIT_HBROOT_ hb_PathNormalize( hb_DirSepToOS( hb_DirBase() + "../" ) ) /* must end with dirsep */ -PROCEDURE Main() +PROCEDURE Main( cParam1 ) - LOCAL cVCS := VCSDetect() - - LOCAL aFiles := {} - LOCAL aChanges := DoctorChanges( cVCS, Changes( cVCS ), aFiles ) + LOCAL cVCS + LOCAL aFiles + LOCAL aChanges LOCAL cLog LOCAL nStart, nEnd LOCAL cMyName LOCAL cLogName LOCAL lWasChangeLog + IF "--prepare-commit" $ hb_CmdLine() + hb_MemoWrit( cParam1, GetLastEntry( MemoRead( FindChangeLog() ) ) + hb_eol() + hb_MemoRead( cParam1 ) ) + ErrorLevel( 0 ) + RETURN + ENDIF + InstallPreCommitHook() + cVCS := VCSDetect() + aFiles := {} + aChanges := DoctorChanges( cVCS, Changes( cVCS ), aFiles ) + IF Empty( aChanges ) OutStd( hb_ProgName() + ": " + "no changes" + hb_eol() ) ErrorLevel( 0 ) @@ -56,12 +65,10 @@ PROCEDURE Main() IF CheckFileList( aFiles ) - IF ! hb_FileExists( cLogName := _COMMIT_HBROOT_ + "ChangeLog.txt" ) - IF ! hb_FileExists( cLogName := _COMMIT_HBROOT_ + "ChangeLog" ) - OutStd( hb_ProgName() + ": " + "cannot find ChangeLog file" + hb_eol() ) - ErrorLevel( 2 ) - RETURN - ENDIF + cLogName := FindChangeLog() + IF Empty( cLogName ) + OutStd( hb_ProgName() + ": " + "cannot find ChangeLog file" + hb_eol() ) + ErrorLevel( 2 ) ENDIF IF "--check-only" $ hb_CmdLine() @@ -142,6 +149,17 @@ STATIC FUNCTION InstallPreCommitHook() RETURN hb_MemoWrit( cName, cFile + hb_eol() + cLine + hb_eol() ) +STATIC FUNCTION FindChangeLog() + + LOCAL cLogName + + IF ! hb_FileExists( cLogName := _COMMIT_HBROOT_ + "ChangeLog.txt" ) .AND. ; + ! hb_FileExists( cLogName := _COMMIT_HBROOT_ + "ChangeLog" ) + RETURN "" + ENDIF + + RETURN cLogName + STATIC FUNCTION GetLastEntry( cLog, /* @ */ nStart, /* @ */ nEnd ) LOCAL cLogHeaderExp := "\n[1-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9] UTC[\-+][0-1][0-9][0-5][0-9] [\S ]*" + hb_eol() diff --git a/contrib/hbnetio/tests/netiotst.prg b/contrib/hbnetio/tests/netiotst.prg index bc1bf450a5..c6f9f1197a 100644 --- a/contrib/hbnetio/tests/netiotst.prg +++ b/contrib/hbnetio/tests/netiotst.prg @@ -19,7 +19,7 @@ #define DBFILE "_tst_" #define DBNAME "net:" + DBSERVER + ":" + hb_ntos( DBPORT ) + ":" + ; - DBPASSWD + ":" + DBDIR + "/" + DBFILE + DBPASSWD + ":" + DBDIR + "/" + DBFILE REQUEST DBFCDX