add project menu items for git branche checlout and git pull

This commit is contained in:
Basile Burg 2018-07-11 16:26:35 +02:00
parent 7658621a93
commit 1b9944f733
6 changed files with 178 additions and 1 deletions

BIN
icons/other/git.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

BIN
icons/other/git24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

BIN
icons/other/git32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

View File

@ -13,7 +13,7 @@
<DpiAware Value="True/PM"/>
</XPManifest>
<Icon Value="0"/>
<Resources Count="376">
<Resources Count="379">
<Resource_0 FileName="..\icons\arrow\arrow_up.png" Type="RCDATA" ResourceName="ARROW_UP"/>
<Resource_1 FileName="..\icons\arrow\arrow_down.png" Type="RCDATA" ResourceName="ARROW_DOWN"/>
<Resource_2 FileName="..\icons\arrow\arrow_divide.png" Type="RCDATA" ResourceName="ARROW_DIVIDE"/>
@ -390,6 +390,9 @@
<Resource_373 FileName="../icons/other/check_boxes_series.png" Type="RCDATA" ResourceName="CHECK_BOXES_SERIES"/>
<Resource_374 FileName="../icons/other/check_boxes_series24.png" Type="RCDATA" ResourceName="CHECK_BOXES_SERIES24"/>
<Resource_375 FileName="../icons/other/check_boxes_series32.png" Type="RCDATA" ResourceName="CHECK_BOXES_SERIES32"/>
<Resource_376 FileName="../icons/other/git.png" Type="RCDATA" ResourceName="GIT"/>
<Resource_377 FileName="../icons/other/git24.png" Type="RCDATA" ResourceName="GIT24"/>
<Resource_378 FileName="../icons/other/git32.png" Type="RCDATA" ResourceName="GIT32"/>
</Resources>
</General>
<i18n>

View File

@ -1713,6 +1713,15 @@ object CEMainForm: TCEMainForm
object MenuItem110: TMenuItem
Action = actProjTest
end
object MenuItem115: TMenuItem
Caption = '-'
end
object mnuGitBranch: TMenuItem
Caption = 'Git branch...'
end
object MenuItem116: TMenuItem
Action = actProjGitPull
end
end
object MenuItem100: TMenuItem
Caption = 'Projects group'
@ -2287,6 +2296,16 @@ object CEMainForm: TCEMainForm
Caption = 'New project dialog...'
OnExecute = actProjNewDialogExecute
end
object actProjGitBranchesUpd: TAction
Category = 'Project'
Caption = 'Update list'
OnExecute = actProjGitBranchesUpdExecute
end
object actProjGitPull: TAction
Category = 'Project'
Caption = 'Git pull'
OnExecute = actProjGitPullExecute
end
end
object ApplicationProperties1: TApplicationProperties
OnActivate = ApplicationProperties1Activate

View File

@ -117,6 +117,8 @@ type
actFileCloseAll: TAction;
actFileNewClip: TAction;
actEdFormat: TAction;
actProjGitPull: TAction;
actProjGitBranchesUpd: TAction;
actProjNewDialog: TAction;
actProjStopComp: TAction;
actProjTest: TAction;
@ -178,6 +180,9 @@ type
MenuItem112: TMenuItem;
MenuItem113: TMenuItem;
MenuItem114: TMenuItem;
MenuItem115: TMenuItem;
MenuItem116: TMenuItem;
mnuGitBranch: TMenuItem;
mnuItemDubDialog: TMenuItem;
mnuItemHelp: TMenuItem;
mnuItemAbout: TMenuItem;
@ -304,6 +309,8 @@ type
procedure actNewGroupExecute(Sender: TObject);
procedure actProjAddToGroupExecute(Sender: TObject);
procedure actProjDscanExecute(Sender: TObject);
procedure actProjGitBranchesUpdExecute(Sender: TObject);
procedure actProjGitPullExecute(Sender: TObject);
procedure actProjGroupCompileCustomSyncExecute(Sender: TObject);
procedure actProjGroupCompileExecute(Sender: TObject);
procedure actProjGroupCompileSyncExecute(Sender: TObject);
@ -377,6 +384,7 @@ type
private
fGitIconIndex: integer;
fImages: TImageList;
fOptionCategories: TCEEditableOptionsSubject;
fRunnablesOptions: TCEEditableRunnableOptions;
@ -527,6 +535,9 @@ type
procedure layoutSaveToFile(const fname: string);
procedure layoutUpdateMenu;
// git
procedure gitBranchMenuItemClick(sender: TObject);
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
@ -1517,6 +1528,14 @@ begin
i := loadIcon('CROSS');
actProjStopComp.ImageIndex:=i;
i := loadIcon('GIT');
fGitIconIndex := i;
mnuGitBranch.ImageIndex:=i;
actProjGitPull.ImageIndex:=i;
i := loadIcon('AROOW_UPDATE');
actProjGitBranchesUpd.ImageIndex:=i;
end;
procedure TCEMainForm.InitWidgets;
@ -2427,6 +2446,9 @@ begin
else if project = fFreeProj then
fFreeProj := nil;
if assigned(fProject) then
actProjGitBranchesUpdExecute(nil);
showProjTitle;
end;
@ -3993,6 +4015,139 @@ begin
end;
end;
procedure TCEMainForm.actProjGitPullExecute(Sender: TObject);
var
p: TProcess;
r: TStringList;
i: integer;
b: string;
begin
p := TProcess.Create(nil);
r := TStringList.Create;
try
p.Executable := exeFullName('git' + exeExt);
if p.Executable.fileExists then
begin
p.Options := [poUsePipes, poNoConsole];
p.ShowWindow:= swoHIDE;
p.Parameters.Add('pull');
//p.Parameters.Add('&&');
//p.Parameters.Add('git');
//p.Parameters.Add('submodule');
//p.Parameters.Add('--update');
//p.Parameters.Add('--init');
//p.Parameters.Add('--recursive');
p.CurrentDirectory:= fProject.basePath;
p.Execute;
processOutputToStrings(p,r);
for i := 0 to r.Count-1 do
fMsgs.message(r[i], fProject, amcProj, amkInf);
r.Clear;
r.LoadFromStream(p.Stderr);
for i := 0 to r.Count-1 do
fMsgs.message(r[i], fProject, amcProj, amkErr);
end;
finally;
actProjGitBranchesUpd.Execute;
p.Free;
r.Free;
end;
end;
procedure TCEMainForm.gitBranchMenuItemClick(sender: TObject);
var
p: TProcess;
r: TStringList;
i: integer;
b: string;
begin
p := TProcess.Create(nil);
r := TStringList.Create;
b := TMenuItem(sender).Caption;
try
p.Executable := exeFullName('git' + exeExt);
if p.Executable.fileExists then
begin
p.Options := [poUsePipes, poNoConsole];
p.ShowWindow:= swoHIDE;
p.Parameters.Add('checkout');
p.Parameters.Add(b);
p.CurrentDirectory:= fProject.basePath;
p.Execute;
processOutputToStrings(p,r);
r.Clear;
r.LoadFromStream(p.Stderr);
// git bug ? even on success they write the switch in stderr
if r.Count > 1 then
begin
for i := 0 to r.Count-1 do
fMsgs.message(r[i], fProject, amcProj, amkErr);
end
else
begin
fMsgs.message('now on branch `' + b + '`', fProject, amcProj, amkInf);
end;
end;
finally;
actProjGitBranchesUpd.Execute;
p.Free;
r.Free;
end;
end;
procedure TCEMainForm.actProjGitBranchesUpdExecute(Sender: TObject);
var
p: TProcess;
r: TStringList;
i: integer;
m: TMenuItem;
begin
mnuGitBranch.Clear;
p := TProcess.Create(nil);
r := TStringList.Create;
try
p.Executable := exeFullName('git' + exeExt);
if p.Executable.fileExists then
begin
p.Options := [poUsePipes, poNoConsole];
p.ShowWindow:= swoHIDE;
p.Parameters.Add('branch');
p.Parameters.Add('--list');
p.CurrentDirectory:= fProject.basePath;
p.Execute;
processOutputToStrings(p,r);
m := TMenuItem.Create(mnuGitBranch);
m.action := actProjGitBranchesUpd;
mnuGitBranch.Add(m);
mnuGitBranch.AddSeparator;
for i:= 0 to r.Count-1 do
begin
m := TMenuItem.Create(mnuGitBranch);
m.GroupIndex := 45;
m.RadioItem:= true;
m.ImageIndex:=fGitIconIndex;
m.OnClick:= @gitBranchMenuItemClick;
if r[i][1] = '*' then
begin
m.Caption:= Trim(r[i][2..r[i].length]);
m.Checked:= true;
end
else m.Caption:= Trim(r[i][1..r[i].length]);
mnuGitBranch.Add(m);
end;
r.Clear;
r.LoadFromStream(p.Stderr);
if r.Count <> 0 then
for i := 0 to r.Count-1 do
fMsgs.message(r[i], fProject, amcProj, amkErr);
end;
finally
p.Free;
r.Free;
end;
end;
procedure TCEMainForm.actProjOpenGroupExecute(Sender: TObject);
begin
if fProjectGroup.groupModified then