1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-04-08 02:18:33 +02:00

Improve Diffusion parsing of submoudule changes

Summary: We currently parse these as directory changes and discard them. Instead, parse them as a new "SUBMODULE" type of change.

Test Plan:
  - Reparsed a commit which changes submodules and verified it parses correctly.
  - Reparsed a commit which adds submodules and verified it parses correctly.

Reviewers: btrahan, kdeggelman

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1815
This commit is contained in:
epriestley 2012-03-07 14:24:43 -08:00
parent afe38572fe
commit 8dfe8e84f0
3 changed files with 19 additions and 7 deletions

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,6 +36,7 @@ final class DifferentialChangeType {
const FILE_SYMLINK = 5; const FILE_SYMLINK = 5;
const FILE_DELETED = 6; const FILE_DELETED = 6;
const FILE_NORMAL = 7; const FILE_NORMAL = 7;
const FILE_SUBMODULE = 8;
public static function getSummaryCharacterForChangeType($type) { public static function getSummaryCharacterForChangeType($type) {
static $types = array( static $types = array(
@ -60,6 +61,7 @@ final class DifferentialChangeType {
self::FILE_IMAGE => 'img', self::FILE_IMAGE => 'img',
self::FILE_BINARY => 'bin', self::FILE_BINARY => 'bin',
self::FILE_SYMLINK => 'sym', self::FILE_SYMLINK => 'sym',
self::FILE_SUBMODULE => 'sub',
); );
return idx($names, coalesce($type, '?'), '???'); return idx($names, coalesce($type, '?'), '???');
} }

View file

@ -1544,6 +1544,7 @@ class DifferentialChangesetParser {
DifferentialChangeType::FILE_DIRECTORY => 'directory', DifferentialChangeType::FILE_DIRECTORY => 'directory',
DifferentialChangeType::FILE_BINARY => 'binary file', DifferentialChangeType::FILE_BINARY => 'binary file',
DifferentialChangeType::FILE_SYMLINK => 'symlink', DifferentialChangeType::FILE_SYMLINK => 'symlink',
DifferentialChangeType::FILE_SUBMODULE => 'submodule',
); );
static $changes = array( static $changes = array(

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -63,13 +63,22 @@ class PhabricatorRepositoryGitCommitChangeParserWorker
$old_mode = intval($old_mode, 8); $old_mode = intval($old_mode, 8);
$new_mode = intval($new_mode, 8); $new_mode = intval($new_mode, 8);
$file_type = DifferentialChangeType::FILE_NORMAL; switch ($new_mode & 0160000) {
if ($new_mode & 040000) { case 0160000:
$file_type = DifferentialChangeType::FILE_DIRECTORY; $file_type = DifferentialChangeType::FILE_SUBMODULE;
} else if ($new_mode & 0120000) { break;
case 0120000:
$file_type = DifferentialChangeType::FILE_SYMLINK; $file_type = DifferentialChangeType::FILE_SYMLINK;
break;
case 0040000:
$file_type = DifferentialChangeType::FILE_DIRECTORY;
break;
default:
$file_type = DifferentialChangeType::FILE_NORMAL;
break;
} }
// TODO: We can detect binary changes as git does, through a combination // TODO: We can detect binary changes as git does, through a combination
// of running 'git check-attr' for stuff like 'binary', 'merge' or 'diff', // of running 'git check-attr' for stuff like 'binary', 'merge' or 'diff',
// and by falling back to inspecting the first 8,000 characters of the // and by falling back to inspecting the first 8,000 characters of the