@@ -72,6 +72,9 @@ abstract class Patch
72
72
/** @ManyToMany(targetEntity="User") */
73
73
public $ students ;
74
74
75
+ /** @Column(length=64) */
76
+ public string $ hash = '' ;
77
+
75
78
/** @Column */
76
79
public int $ lines_added ;
77
80
@@ -94,16 +97,17 @@ static function factory(ProjGroup $group, string $url, $type,
94
97
$ p ->type = (int )$ type ;
95
98
$ p ->issue_url = check_url ($ issue_url );
96
99
97
- $ description = trim ($ description );
98
- $ p ->comments ->add (
99
- new PatchComment ($ p , "Patch submitted \n$ description " , $ submitter ));
100
-
101
100
try {
102
101
$ p ->updateStats ();
103
102
} catch (Exception $ ex ) {
104
103
throw new ValidationException ('Patch not found ' );
105
104
}
106
105
106
+ $ description = trim ($ description );
107
+ $ p ->comments ->add (
108
+ new PatchComment ($ p , "Patch submitted; hash: {$ p ->hash }\n\n$ description " ,
109
+ $ submitter ));
110
+
107
111
try {
108
112
if (!$ description )
109
113
throw new ValidationException ("Empty description " );
@@ -154,7 +158,7 @@ static function factory(ProjGroup $group, string $url, $type,
154
158
"the end \n$ msg " );
155
159
}
156
160
}
157
- }
161
+ }
158
162
159
163
check_reasonable_name ($ commit ['name ' ], $ group );
160
164
check_wrapped_commit_text ($ msg , 72 );
@@ -206,6 +210,7 @@ abstract public function isValid() : bool;
206
210
abstract public function branch () : string ;
207
211
abstract public function origin () : string ;
208
212
abstract public function commits () : array ;
213
+ abstract protected function computeBranchHash () : string ;
209
214
abstract protected function computeLinesAdded () : int ;
210
215
abstract protected function computeLinesDeleted () : int ;
211
216
abstract protected function computeFilesModified () : int ;
@@ -214,6 +219,8 @@ abstract public function setPR(PullRequest $pr);
214
219
abstract public function getPR () : ?PullRequest ;
215
220
216
221
public function updateStats () {
222
+ $ this ->hash = $ this ->computeBranchHash ();
223
+
217
224
if ($ pr = $ this ->getPR ()) {
218
225
$ legal = $ this ->status == PATCH_PR_OPEN ;
219
226
if ($ pr ->wasMerged ()) {
0 commit comments