source: trunk/Backends/Git/UGit.pas

Last change on this file was 13, checked in by chronos, 9 years ago
  • Added: New test form where general functionality of selected backend can be tested.
  • Added: Basic git backend implementation.
  • Added: Project group form and ability to open/save group of projects as configuration to XML file.
File size: 2.2 KB
Line 
1unit UGit;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UVCS, UBackend;
9
10type
11
12 { TBackendGit }
13
14 TBackendGit = class(TBackend)
15 constructor Create;
16 function IsWorkingCopy(Directory: string): Boolean; override;
17 end;
18
19
20 { TGit }
21
22 TGit = class(TWorkingCopy)
23 protected
24 procedure Execute(Parameters: array of string);
25 public
26 procedure Checkout; override;
27 procedure Update; override;
28 procedure CleanUp; override;
29 procedure Commit(Message: TStrings); override;
30 procedure Move(Source, Dest: string); override;
31 procedure Merge; override;
32 procedure Add(FileName: string); override;
33 procedure GetLog(FileName: string; Log: TLogList); override;
34 end;
35
36 { TRepositoryGit }
37
38 TRepositoryGit = class(TRepository)
39 protected
40 procedure Execute(Parameters: array of string);
41 public
42 procedure Init; override;
43 end;
44
45
46implementation
47
48{ TRepositoryGit }
49
50procedure TRepositoryGit.Execute(Parameters: array of string);
51begin
52 ExecuteProcess('/usr/bin/git', Parameters);
53end;
54
55procedure TRepositoryGit.Init;
56begin
57 Execute(['init', Path]);
58end;
59
60{ TBackendGit }
61
62constructor TBackendGit.Create;
63begin
64 Name := 'Git';
65 HomePage := 'https://git-scm.com/';
66 WorkingCopyClass := TGit;
67 RepositoryClass := TRepositoryGit;
68end;
69
70function TBackendGit.IsWorkingCopy(Directory: string): Boolean;
71begin
72 Result := DirectoryExists(Directory + DirectorySeparator + '.git');
73end;
74
75{ TGit }
76
77procedure TGit.Execute(Parameters: array of string);
78begin
79 ExecuteProcess('/usr/bin/git', Parameters);
80end;
81
82procedure TGit.Checkout;
83begin
84 Execute(['clone', RepositoryURL, Path]);
85end;
86
87procedure TGit.Update;
88begin
89 Execute(['fetch']);
90end;
91
92procedure TGit.CleanUp;
93begin
94 Execute(['cleanup']);
95end;
96
97procedure TGit.Commit(Message: TStrings);
98begin
99 Execute(['config', 'user.name "' + UserName + '"']);
100 Execute(['config', 'user.email "' + Email + '"']);
101 Execute(['commit', '-m "' + Message.Text + '"']);
102end;
103
104procedure TGit.Move(Source, Dest: string);
105begin
106 Execute(['mv', Source, Dest]);
107end;
108
109procedure TGit.Merge;
110begin
111 Execute(['merge']);
112end;
113
114procedure TGit.Add(FileName: string);
115begin
116 Execute(['add', FileName]);
117end;
118
119procedure TGit.GetLog(FileName: string; Log: TLogList);
120begin
121end;
122
123end.
124
Note: See TracBrowser for help on using the repository browser.