[Gambas-devel] Sample release for automatic changelog generator
Yizhou He
yizhou_he at ...143...
Sat Aug 7 09:21:09 CEST 2004
Hi:
Since I got no comments on this idea. I guess I need release a
sample release. This is a crude version. Just finished
1. Automatic backup a class file before first save. all the change
log will base on this backup.
2. Compare backup class file and saved file
3. Write changed function or sub into Changelog+version .txt file
4. Only after you change version number, it will make new backup
and all the change will based on the new version.
This version only narrow down to function or sub. later version
will be able to mark changed lines.
Comment and suggestion needed.
thanks
'--------Changed function in class FEditor---------
PUBLIC FUNCTION Save() AS Boolean
DIM iLig AS Integer
DIM iProc AS Integer
DIM iFull AS Integer
DIM sLig AS String
DIM iPosProc AS Integer
DIM sData AS String
DIM iLine AS Integer
DIM iCol AS Integer
DIM bChange AS Boolean
DIM iCount AS Integer
DIM iVoidLine AS Integer
'---Yizhou He Start----
DIM iBackup AS Integer
DIM iSaved AS Integer
DIM sBackup AS String
DIM sSaved AS String
DIM aBackup AS String[]
DIM aSaved AS String[]
DIM sChange AS String
DIM iInd AS Integer
IF NOT Exist(path & "." & project.Version) THEN COPY path TO path
& "." & project.Version
CreateMenu
'---Yizhou He Ended---
IF Project.ReadOnly THEN RETURN
IF NOT $bModify THEN RETURN
Save.Begin(Path)
IF $bCleanOnSave THEN
iProc = -1
iLine = edtEditor.Line
iCol = edtEditor.Column
iCount = edtEditor.Lines.Count
FOR iLig = 0 TO iCount
IF iLig < iCount THEN
sLig = RTrim(edtEditor.Lines[iLig])
ELSE
sLig = "SUB gambas()"
ENDIF
IF NOT LTrim(sLig) THEN
INC iVoidLine
CONTINUE
ENDIF
IF IsProc(sLig) THEN
IF iProc >= 0 THEN
IF iFull < 2 THEN
bChange = TRUE
sData = Left(sData, iPosProc)
IF iLine > iProc THEN
IF iLine < iLig THEN
iLine = iProc - 1
ELSE
iLine = iLine - (iLig - iProc + 1)
ENDIF
ENDIF
ENDIF
ENDIF
iProc = iLig
iFull = 0
iPosProc = Len(sData)
ELSE
INC iFull
ENDIF
IF iLig < iCount THEN
sData = sData & String(iVoidLine, "\n") & sLig & "\n"
iVoidLine = 0
ENDIF
NEXT
IF Len(sData) <> Len(edtEditor.Text) THEN
File.Save(Path, sData)
edtEditor.Frozen = TRUE
edtEditor.Text = sData
TRY edtEditor.Line = iLine
IF Error = 0 THEN
TRY edtEditor.Column = iCol
ENDIF
edtEditor.Frozen = FALSE
ENDIF
ENDIF
IF NOT bChange THEN File.Save(Path, edtEditor.Text)
$bModify = FALSE
DrawTitle
Save.End()
'--------Yizhou He Start----------------------
IF NOT bChange THEN
sSaved=edtEditor.Text & "\n"
sBackup=File.Load(path & "." & project.Version) & "\n"
iBackup=1
iInd=0
aBackup=NEW String[]
aSaved=NEW String[]
WHILE iBackup>0
iSaved=iBackup
iBackup=Instr(sBackup,"\nEND\n",iBackup+1)
IF iBackup>0 THEN
aBackup.Add(Mid(sBackup,iSaved,iBackup-iSaved+5),iInd)
iBackup=iBackup+5
iInd=iInd+1
ENDIF
WEND
iBackup=1
iInd=0
WHILE iBackup>0
iSaved=iBackup
iBackup=Instr(sSaved,"\nEND\n",iBackup+1)
IF iBackup>0 THEN
aSaved.Add(Mid(sSaved,iSaved,iBackup-iSaved+5),iInd)
iBackup=iBackup+5
iInd=iInd+1
ENDIF
WEND
iBackup=0
iSaved=0
FOR EACH sBackup IN aBackup
FOR EACH sSaved IN aSaved
IF Trim(sBackup)=Trim(sSaved) THEN
aBackup[iBackup]=""
aSaved[iSaved]=""
EXIT
ENDIF
iSaved=iSaved+1
NEXT
iBackup=iBackup+1
iSaved=0
NEXT
sChange=""
IF Exist(File.Dir(path) & "/Changelog" & project.Version &
".txt") THEN
sChange=File.Load(File.Dir(path) & "/Changelog" &
project.Version & ".txt")
IF Instr(sChange,"'#----Changes in class " & Name & "
Start----\n\n")>0 THEN
iBackup=Instr(sChange,"'#----Changes in class " & Name & "
Start----\n\n")
iSaved=Instr(sChange,"'#----Changes in class " & Name & "
Ended----\n\n")+Len("'#----Changes in class " & Name & "
Ended----\n\n")
sChange=Left(sChange,iBackup) &
Right(sChange,Len(sChange)-iSaved)
ENDIF
ENDIF
sChange=sChange & "'#----Changes in class " & Name & "
Start----\n\n"
sChange=sChange & "'#----Sub that will be removed----\n\n"
FOR EACH sBackup IN aBackup
IF Trim(sBackup)<>"" THEN sChange=sChange & Trim(sBackup) &
"\n"
NEXT
sChange=sChange & "'#----Sub that will be added----\n\n"
FOR EACH sSaved IN aSaved
IF Trim(sSaved)<>"" THEN sChange=sChange & Trim(sSaved) & "\n"
NEXT
sChange=sChange & "'#----Changes in class " & Name & "
Ended----\n\n"
file.Save(File.Dir(path) & "/Changelog " & project.Version &
".txt",sChange)
ENDIF
'--------Yizhou He Ended----------------------
CATCH
RETURN Save.Error()
END
Yizhou He
Research Technician (Xiong Lab)
Lineberger Comprehensive Cancer Center
University of North Carolina at Chapel Hill
Chapel Hill, NC 27599-7295
Tel: (919)-962-2143
More information about the Devel
mailing list