Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F91653
D7793.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D7793.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -482,6 +482,7 @@
'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php',
'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionCommitParentsQuery.php',
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
+ 'DiffusionCommitRef' => 'applications/diffusion/data/DiffusionCommitRef.php',
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php',
'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php',
@@ -506,6 +507,7 @@
'DiffusionLintController' => 'applications/diffusion/controller/DiffusionLintController.php',
'DiffusionLintDetailsController' => 'applications/diffusion/controller/DiffusionLintDetailsController.php',
'DiffusionLintSaveRunner' => 'applications/diffusion/DiffusionLintSaveRunner.php',
+ 'DiffusionLowLevelGitCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitCommitQuery.php',
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
@@ -2866,6 +2868,7 @@
'DiffusionCommitHookRejectException' => 'Exception',
'DiffusionCommitParentsQuery' => 'DiffusionQuery',
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'DiffusionCommitRef' => 'Phobject',
'DiffusionCommitTagsController' => 'DiffusionController',
'DiffusionController' => 'PhabricatorController',
'DiffusionDiffController' => 'DiffusionController',
@@ -2887,6 +2890,7 @@
'DiffusionLastModifiedController' => 'DiffusionController',
'DiffusionLintController' => 'DiffusionController',
'DiffusionLintDetailsController' => 'DiffusionController',
+ 'DiffusionLowLevelGitCommitQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelQuery' => 'Phobject',
diff --git a/src/applications/diffusion/data/DiffusionCommitRef.php b/src/applications/diffusion/data/DiffusionCommitRef.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/data/DiffusionCommitRef.php
@@ -0,0 +1,59 @@
+<?php
+
+final class DiffusionCommitRef extends Phobject {
+
+ private $message;
+ private $authorName;
+ private $authorEmail;
+ private $committerName;
+ private $committerEmail;
+
+ public function setCommitterEmail($committer_email) {
+ $this->committerEmail = $committer_email;
+ return $this;
+ }
+
+ public function getCommitterEmail() {
+ return $this->committerEmail;
+ }
+
+
+ public function setCommitterName($committer_name) {
+ $this->committerName = $committer_name;
+ return $this;
+ }
+
+ public function getCommitterName() {
+ return $this->committerName;
+ }
+
+
+ public function setAuthorEmail($author_email) {
+ $this->authorEmail = $author_email;
+ return $this;
+ }
+
+ public function getAuthorEmail() {
+ return $this->authorEmail;
+ }
+
+
+ public function setAuthorName($author_name) {
+ $this->authorName = $author_name;
+ return $this;
+ }
+
+ public function getAuthorName() {
+ return $this->authorName;
+ }
+
+ public function setMessage($message) {
+ $this->message = $message;
+ return $this;
+ }
+
+ public function getMessage() {
+ return $this->message;
+ }
+
+}
diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitCommitQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitCommitQuery.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelGitCommitQuery.php
@@ -0,0 +1,48 @@
+<?php
+
+final class DiffusionLowLevelGitCommitQuery extends DiffusionLowLevelQuery {
+
+ private $identifier;
+
+ public function withIdentifier($identifier) {
+ $this->identifier = $identifier;
+ return $this;
+ }
+
+ protected function executeQuery() {
+ $repository = $this->getRepository();
+
+ // NOTE: %B was introduced somewhat recently in git's history, so pull
+ // commit message information with %s and %b instead.
+
+ // Even though we pass --encoding here, git doesn't always succeed, so
+ // we try a little harder, since git *does* tell us what the actual encoding
+ // is correctly (unless it doesn't; encoding is sometimes empty).
+ list($info) = $repository->execxLocalCommand(
+ 'log -n 1 --encoding=%s --format=%s %s --',
+ 'UTF-8',
+ implode('%x00', array('%e', '%cn', '%ce', '%an', '%ae', '%s%n%n%b')),
+ $this->identifier);
+
+ $parts = explode("\0", $info);
+ $encoding = array_shift($parts);
+
+ foreach ($parts as $key => $part) {
+ if ($encoding) {
+ $part = phutil_utf8_convert($part, 'UTF-8', $encoding);
+ }
+ $parts[$key] = phutil_utf8ize($part);
+ if (!strlen($parts[$key])) {
+ $parts[$key] = null;
+ }
+ }
+
+ return id(new DiffusionCommitRef())
+ ->setCommitterName($parts[0])
+ ->setCommitterEmail($parts[1])
+ ->setAuthorName($parts[2])
+ ->setAuthorEmail($parts[3])
+ ->setMessage($parts[4]);
+ }
+
+}
diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
--- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
+++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php
@@ -7,32 +7,16 @@
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
- // NOTE: %B was introduced somewhat recently in git's history, so pull
- // commit message information with %s and %b instead.
- // Even though we pass --encoding here, git doesn't always succeed, so
- // we try a little harder, since git *does* tell us what the actual encoding
- // is correctly (unless it doesn't; encoding is sometimes empty).
- list($info) = $repository->execxLocalCommand(
- 'log -n 1 --encoding=%s --format=%s %s --',
- 'UTF-8',
- implode('%x00', array('%e', '%cn', '%ce', '%an', '%ae', '%s%n%n%b')),
- $commit->getCommitIdentifier());
-
- $parts = explode("\0", $info);
- $encoding = array_shift($parts);
-
- foreach ($parts as $key => $part) {
- if ($encoding) {
- $part = phutil_utf8_convert($part, 'UTF-8', $encoding);
- }
- $parts[$key] = phutil_utf8ize($part);
- }
-
- $committer_name = $parts[0];
- $committer_email = $parts[1];
- $author_name = $parts[2];
- $author_email = $parts[3];
- $message = $parts[4];
+ $ref = id(new DiffusionLowLevelGitCommitQuery())
+ ->setRepository($repository)
+ ->withIdentifier($commit->getCommitIdentifier())
+ ->execute();
+
+ $committer_name = $ref->getCommitterName();
+ $committer_email = $ref->getCommitterEmail();
+ $author_name = $ref->getAuthorName();
+ $author_email = $ref->getAuthorEmail();
+ $message = $ref->getMessage();
if (strlen($author_email)) {
$author = "{$author_name} <{$author_email}>";
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/os/jd/b25uzsw6gtqtlhjq
Default Alt Text
D7793.diff (7 KB)
Attached To
Mode
D7793: Move git commit metadata parsing into a LowLevelQuery
Attached
Detach File
Event Timeline
Log In to Comment