diff --git a/cvsinfo.pas b/cvsinfo.pas index eb4476b..017fb79 100644 --- a/cvsinfo.pas +++ b/cvsinfo.pas @@ -44,32 +44,50 @@ procedure Tf_CVSInfo.BtnOKClick(Sender: TObject); i, words: integer; s: string; begin - // ________________________________________________ Count words in message ___ - s := Trim(cvs_comment.Text); - words := 0; - for i := 1 to Length(s) do + // _______________________________________________________ Git integration ___ + if f_work.gitIntegrated then begin - if s[i] = ' ' then + if Trim(cvs_comment.Text) = '' then begin - Inc(words); + ShowMessage('Please provide a commit message!'); + Exit; + end + else + begin + // _____________________________________________________ Compose result ___ + f_work.CVSCheckInData := Trim(cvs_comment.Text); end; - end; - Inc(words); - // ______________________________________________ Check minimal conditions ___ - if (words < 3) and (Length(s) < 20) then - begin - ShowMessage('Comment is too short.' + #13 + #10 + - 'Please write something more..!'); - Exit; end - else if Trim(cvs_worksheet.Text) = '' then + else + // _______________________________________________ Generic CVS integration ___ begin - ShowMessage('Please provide a worksheet code!'); - Exit; + // ______________________________________________ Count words in message ___ + s := Trim(cvs_comment.Text); + words := 0; + for i := 1 to Length(s) do + begin + if s[i] = ' ' then + begin + Inc(words); + end; + end; + Inc(words); + // ____________________________________________ Check minimal conditions ___ + if (words < 3) and (Length(s) < 20) then + begin + ShowMessage('Comment is too short.' + #13 + #10 + + 'Please write something more..!'); + Exit; + end + else if Trim(cvs_worksheet.Text) = '' then + begin + ShowMessage('Please provide a worksheet code!'); + Exit; + end; + // ______________________________________________________ Compose result ___ + f_work.CVSCheckInData := Trim(cvs_worksheet.Text) + ' - ' + + Trim(cvs_comment.Text); end; - // ________________________________________________________ Compose result ___ - f_work.CVSCheckInData := Trim(cvs_worksheet.Text) + ' - ' + - Trim(cvs_comment.Text); ModalResult := mrOk; end; @@ -77,6 +95,12 @@ procedure Tf_CVSInfo.FormShow(Sender: TObject); begin cvs_comment.Text := ''; cvs_worksheet.Text := ''; + if f_work.gitIntegrated then + begin + Label2.Visible := False; + cvs_worksheet.Visible := False; + cvs_comment.Height := 180; + end; cvs_comment.SetFocus; end; diff --git a/jxob.ini b/jxob.ini index 632202c..808a1f9 100644 --- a/jxob.ini +++ b/jxob.ini @@ -25,10 +25,11 @@ temp_dir= design_report= cvs_versioning=0 layer=0 +git=1 [Recent] app1=C:\Devel\projects\dev\htdocs\dev.php -app3=C:\Devel\projects\evision_saas\htdocs\evision_saas.php -app4=C:\Devel\projects\ekovision\htdocs\ekovision.php +app3=C:\Devel\projects\ekovision\htdocs\ekovision.php +app4=C:\Devel\projects\evision_saas\htdocs\evision_saas.php ; --- Recently opened projects ; This is a list of proposed projects, in the form ; app=, where is a progressive number and diff --git a/login.pas b/login.pas index 81c0108..f4afbc4 100644 --- a/login.pas +++ b/login.pas @@ -96,7 +96,8 @@ procedure Tf_login.FormShow(Sender: TObject); f_work.e_res_y.Text := f_work.settings.ReadString('Forms', 'Resolution_y', '768'); - loginOK := False; + loginOK := False; + end; diff --git a/preferences.dfm b/preferences.dfm index 0a9be5b..e6a1b08 100644 --- a/preferences.dfm +++ b/preferences.dfm @@ -1,7 +1,7 @@ object f_config: Tf_config Left = 432 Top = 176 - Width = 405 + Width = 440 Height = 620 Caption = 'Settings' Color = clBtnFace @@ -23,12 +23,12 @@ object f_config: Tf_config Caption = 'Call Program' end object PageControl1: TPageControl - Left = 0 + Left = 20 Top = 73 - Width = 397 + Width = 400 Height = 469 ActivePage = ts_generale - Align = alClient + Align = alCustom TabOrder = 0 object ts_generale: TTabSheet Caption = 'General' @@ -68,6 +68,42 @@ object f_config: Tf_config Caption = 'Development layer:' Visible = False end + object Label23: TLabel + Left = 24 + Top = 280 + Width = 156 + Height = 13 + Caption = 'Integrate local versioning system:' + end + object Label24: TLabel + Left = 55 + Top = 324 + Width = 314 + Height = 29 + AutoSize = False + Caption = + 'If ".git" folder is found in application root, then Git will be ' + + 'used to COMMIT each CHECK-IN.' + WordWrap = True + end + object Label25: TLabel + Left = 55 + Top = 400 + Width = 314 + Height = 30 + AutoSize = False + Caption = + '"check-in.bat" and "check-out.bat" scripts must be provided in B' + + 'uilder folder.' + WordWrap = True + end + object Label26: TLabel + Left = 55 + Top = 355 + Width = 232 + Height = 13 + Caption = 'NOTE: "git" command must be provided to CMD.' + end object e_def_user: TEdit Left = 170 Top = 20 @@ -135,14 +171,14 @@ object f_config: Tf_config OnClick = PathButton3Click end object e_cvs: TCheckBox - Left = 20 - Top = 280 - Width = 337 + Left = 36 + Top = 380 + Width = 245 Height = 21 - Caption = 'Integrate external CVS' + Caption = 'Other CVS' Ctl3D = False ParentCtl3D = False - TabOrder = 8 + TabOrder = 9 end object e_layer: TComboBox Left = 170 @@ -157,6 +193,16 @@ object f_config: Tf_config 'Application core' 'Overriding layer') end + object e_git: TCheckBox + Left = 36 + Top = 304 + Width = 245 + Height = 21 + Caption = 'Git' + Ctl3D = False + ParentCtl3D = False + TabOrder = 8 + end end object ts_actions: TTabSheet Caption = 'Actions' @@ -1232,13 +1278,13 @@ object f_config: Tf_config object Panel1: TPanel Left = 0 Top = 542 - Width = 397 + Width = 432 Height = 51 Align = alBottom BevelOuter = bvNone TabOrder = 1 object Button1: TButton - Left = 166 + Left = 182 Top = 16 Width = 75 Height = 25 @@ -1250,7 +1296,7 @@ object f_config: Tf_config object Panel2: TPanel Left = 0 Top = 0 - Width = 397 + Width = 432 Height = 73 Align = alTop BevelOuter = bvNone @@ -1267,7 +1313,7 @@ object f_config: Tf_config object e_iniFile: TEdit Left = 20 Top = 38 - Width = 355 + Width = 400 Height = 19 Ctl3D = False ParentCtl3D = False @@ -1276,8 +1322,8 @@ object f_config: Tf_config end end object ActionList1: TActionList - Left = 460 - Top = 192 + Left = 348 + Top = 144 object carica_ini: TAction Caption = 'carica_ini' OnExecute = carica_iniExecute diff --git a/preferences.pas b/preferences.pas index f504100..7d6d248 100644 --- a/preferences.pas +++ b/preferences.pas @@ -70,6 +70,11 @@ Tf_config = class(TForm) e_brackets: TComboBox; e_layer: TComboBox; Label22: TLabel; + Label23: TLabel; + e_git: TCheckBox; + Label24: TLabel; + Label25: TLabel; + Label26: TLabel; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); @@ -112,6 +117,16 @@ procedure Tf_config.Button1Click(Sender: TObject); f_work.settings.WriteInteger('O2_ENV', 'layer', e_layer.ItemIndex); f_work.settings.WriteString('O2_ENV', 'design_report', e_reppath.Text); f_work.settings.WriteBool('O2_ENV', 'cvs_versioning', e_cvs.Checked); + // ________________________________________________ Manage Git integration ___ + f_work.settings.WriteBool('O2_ENV', 'git', e_git.Checked); + if (e_cvs.Checked and DirectoryExists(f_work.workdir + 'git')) then + begin + f_work.gitIntegrated := true; + end + else + begin + f_work.gitIntegrated := false; + end; // __________________________________________ Save brackets mode in editor ___ if e_brackets.ItemIndex = 1 then begin @@ -191,6 +206,7 @@ procedure Tf_config.carica_iniExecute(Sender: TObject); e_cvs.Checked := f_work.settings.ReadBool('O2_ENV', 'cvs_versioning', false); + e_git.Checked := f_work.settings.ReadBool('O2_ENV', 'git', false); brackets := f_work.settings.ReadString('Editor', 'brackets', 'N'); // _____________________________________________________ Only open bracket ___ if brackets = 'O' then diff --git a/work.dfm b/work.dfm index 1252611..c797de1 100644 --- a/work.dfm +++ b/work.dfm @@ -84,7 +84,7 @@ object f_work: Tf_work Top = 32 Width = 870 Height = 602 - ActivePage = ts_programmi + ActivePage = ts_openapp Align = alClient MultiLine = True PopupMenu = pop_pagecontrol1 @@ -837,7 +837,7 @@ object f_work: Tf_work Top = 0 Width = 862 Height = 547 - ActivePage = ts_form + ActivePage = ts_prg_prop Align = alClient Style = tsButtons TabOrder = 1 @@ -2568,7 +2568,7 @@ object f_work: Tf_work OnDblClick = Zoom11Click end object BitBtn5: TBitBtn - Left = 748 + Left = 668 Top = 40 Width = 90 Height = 25 diff --git a/work.pas b/work.pas index f119db2..725d280 100644 --- a/work.pas +++ b/work.pas @@ -595,7 +595,7 @@ Tf_work = class(TForm) function albero_folder(nodo: TTreeNode): string; procedure checkout(Sender: TObject; oggetto: string); - procedure checkin(Sender: TObject; const oggetti: array of string; cvsSet: Boolean); + procedure checkin(Sender: TObject; const oggetti: array of string; cvsSet: Boolean; gitSet: Boolean); procedure uncheck(Sender: TObject; oggetto: string); procedure copia_file(Sender: TObject; origine, destinazione: string); @@ -776,6 +776,7 @@ Tf_work = class(TForm) nodo_temp1: TTreeNode; treemenu_incarica: boolean; elenco_prg_caricato: Boolean; + cmdObj: TDosCommand; public { Public declarations } settings: TIniFile; @@ -800,7 +801,7 @@ Tf_work = class(TForm) nodo_ultimo_selezionato: TTreeNode; ultimo_tabsheet : TTabSheet; CVSCheckInData : string; - + gitIntegrated : Boolean; end; var @@ -896,6 +897,7 @@ procedure Tf_work.apri_progettoExecute(Sender: TObject); Screen.Cursor := crHourGlass; LogProjectLoad('Starting up'); try + begin // __________________________________________________ Logged developer ___ user := e_user.Text; // ___________________________________ Get project name from file name ___ @@ -929,6 +931,16 @@ procedure Tf_work.apri_progettoExecute(Sender: TObject); userdir := prgdir + user + '\'; // ________________________ Load colors from INI file to configuration ___ f_config.carica_ini.Execute(); + // ____________________________________________ Manage Git integration ___ + if (settings.ReadBool('O2_ENV', 'git', false) and + DirectoryExists(workdir + '.git')) then + begin + gitIntegrated := true; + end + else + begin + gitIntegrated := false; + end; // _________________________________________________ Update status bar ___ StatusBar1.Panels[0].Text := ' Project: ' + progetto; StatusBar1.Panels[1].Text := '| Home dir: ' + workdir + @@ -958,12 +970,15 @@ procedure Tf_work.apri_progettoExecute(Sender: TObject); HeaderControl1.Visible := True; supertree.Visible := True; Splitter5.Visible := True; + end finally - LogProjectLoad(); - Screen.Cursor := crDefault; - f_work.create.Enabled := True; - f_work.delete.Enabled := True; - f_work.cancel.Enabled := True; + begin + LogProjectLoad(); + Screen.Cursor := crDefault; + f_work.create.Enabled := True; + f_work.delete.Enabled := True; + f_work.cancel.Enabled := True; + end; end; end; @@ -3315,24 +3330,68 @@ function Tf_work.cvs_checkout(ObjFile: String): Boolean; function Tf_work.cvs_checkin(ObjFile, TmpFile: String): Boolean; var - checkinBat, Params: string; - ResCode: Boolean; + checkinBat, Params, gitBat: string; + cvsSet, ResCode: Boolean; + gitCmd: TStringList; begin - checkinBat := 'check-in.bat'; - Params := f_work.user + - ' ' + f_work.prgdir + - ' ' + ObjFile + - ' ' + TmpFile; - ResCode := ExecAndWait(checkinBat + ' ' + Params); - if ResCode then + cvsSet := f_work.settings.ReadBool('O2_ENV', 'cvs_versioning', false); + if cvsSet then begin - Result := true; - end - else + checkinBat := 'check-in.bat'; + Params := f_work.user + + ' ' + f_work.prgdir + + ' ' + ObjFile + + ' ' + TmpFile; + ResCode := ExecAndWait(checkinBat + ' ' + Params); + if ResCode then + begin + Result := true; + end + else + begin + ShowMessage('Error from external CVS.' + chr(10) + + 'Can' + chr(39) + 't check-in element.'); + Result := false; + end; + end; + // ____________________________________________________ Use integrated Git ___ + if gitIntegrated then begin - ShowMessage('Error from external CVS.' + chr(10) + - 'Can' + chr(39) + 't check-in element.'); - Result := false; + if (RightStr(ObjFile, 4) = '.prf') or (RightStr(ObjFile, 4) = '.prg') then + begin + ObjFile := Copy(ObjFile, 1, length(ObjFile) - 1) + '*'; + end; + gitCmd := TStringList.Create; + gitCmd.Add('cd ' + f_work.prgdir); + gitCmd.Add('git add ' + f_work.prgdir + ObjFile); + gitCmd.Add('git commit ' + f_work.prgdir + ObjFile + + ' --file=' + TmpFile + + ' --author="' + f_work.user + '<' + f_work.user + '@janox.it>"'); + gitBat := f_work.tempdir + 'jxgit' + f_work.user + '.bat'; + gitCmd.SaveToFile(gitBat); + // ___________________________________________________ Execute command ___ + try + begin + ExecAndWait(gitBat); + ResCode := true; + end + except on E : Exception do + begin + ShowMessage(E.Message); + ResCode := false; + end; + end; + if ResCode then + begin + Result := true; + end + else + begin + ShowMessage('Error from Git integration.' + chr(10) + + 'BAT:' + chr(10) + gitBat + chr(10) + + 'Can' + chr(39) + 't check-in ' + ObjFile + '.'); + Result := false; + end; end; end; @@ -3382,7 +3441,8 @@ procedure Tf_work.checkOut(Sender: TObject; oggetto: string); procedure Tf_work.checkin(Sender: TObject; const oggetti: array of string; - cvsSet: Boolean); + cvsSet: Boolean; + gitSet: Boolean); var ori, nuovo: TFileStream; anyError: Boolean; @@ -3415,6 +3475,10 @@ procedure Tf_work.checkin(Sender: TObject; FreeAndNil(nuovo); end; end; + if (gitSet and (not(cvs_checkin(oggetti[0], TmpFile)))) then + begin + anyError := True; + end; // _______________________________ If not error delete files from user dir ___ if not(anyError) then begin @@ -3604,16 +3668,18 @@ procedure Tf_work.check_outExecute(Sender: TObject); procedure Tf_work.check_inExecute(Sender: TObject); var dircds, dircds_user, nomeprg, TmpFile: string; - cvsSet, forzacheckin: Boolean; + cvsSet, gitSet, forzacheckin: Boolean; CVSTempTxt: TStringList; begin + // ________________________________________ Generic CVS and Git versioning ___ cvsSet := f_work.settings.ReadBool('O2_ENV', 'cvs_versioning', false); + gitSet := gitIntegrated; if (MessageDlg('Confirm object check-in?', mtConfirmation, mbOKCancel, 1) = mrOk) then begin - if cvsSet then + if cvsSet or gitIntegrated then begin CVSCheckInData := ''; f_CVSInfo.ShowModal; @@ -3633,7 +3699,10 @@ procedure Tf_work.check_inExecute(Sender: TObject); if PageControl1.ActivePage = ts_appvars then begin f_export.appvars_export.Execute; - checkin(self, [dm_form.t_applicazioneappvars.Value], cvsSet); + checkin(self, + [dm_form.t_applicazioneappvars.Value], + cvsSet, + gitIntegrated); dm_form.appvar_modificato := false; end // ______________________________________________________________ Models ___ @@ -3644,21 +3713,22 @@ procedure Tf_work.check_inExecute(Sender: TObject); [dm_form.t_applicazionemodels.Value, '__source__\models.cache', '__source__\models.md5'], - cvsSet); + cvsSet, + gitIntegrated); dm_form.datatypes_modificato := false; end // ________________________________________________________________ Menu ___ else if PageControl1.ActivePage = ts_menu then begin f_export.menu_export.Execute; - checkin(self, [dm_form.t_applicazionemenus.Value], cvsSet); + checkin(self, [dm_form.t_applicazionemenus.Value], cvsSet, gitIntegrated); dm_form.menu_modificato := false; end // _______________________________________________ Servers and databases ___ else if PageControl1.ActivePage = ts_database then begin f_export.db_export.Execute; - checkin(self, [dm_form.t_applicazionedbs.Value], cvsSet); + checkin(self, [dm_form.t_applicazionedbs.Value], cvsSet, gitIntegrated); dm_form.database_modificato := false; end // ______________________________________________________________ Tables ___ @@ -3674,7 +3744,8 @@ procedure Tf_work.check_inExecute(Sender: TObject); '__source__\nuindexes.cache', '__source__\nusegments.cache', '__source__\tables.md5'], - cvsSet); + cvsSet, + gitIntegrated); dm_form.tables_modificato := false; end // _____________________________________________________________ Program ___ @@ -3698,7 +3769,10 @@ procedure Tf_work.check_inExecute(Sender: TObject); if dm_form.t_programminome.Value <> '_o2viewmodels' then begin nomeprg := dm_form.t_programminome.Value; - checkin(self, [nomeprg + '.prg', nomeprg + '.prf'], cvsSet); + checkin(self, + [nomeprg + '.prg', nomeprg + '.prf'], + cvsSet, + gitIntegrated); // muove i files cds // copia i files sources (cds) dircds := f_work.prgdir + '__source__\' + nomeprg + '\'; @@ -3747,8 +3821,9 @@ procedure Tf_work.check_inExecute(Sender: TObject); begin checkin(self, [dm_form.t_programminome.Value + '.prg', - dm_form.t_applicazioneviews.Value], - cvsSet); + dm_form.t_applicazioneviews.Value], + cvsSet, + gitIntegrated); end; dm_form.program_modificato := false; end;