/** * undocumented function * * @param string $type * @param string $options * @return void */ function find($type = 'all', $options = array()) { if (!empty($options['conditions']['path'])) { $options['path'] = $options['conditions']['path']; unset($options['conditions']['path']); } $options = array_merge(array('path' => '.', 'limit' => 100, 'page' => 1), $options); if (empty($options['path'])) { return false; } $data = $this->look('history', array('path' => $options['path'])); if (preg_match_all('/[\\s+](\\d+)[\\s+]/', $data, $matches)) { $data = array_filter($matches[1]); } if ($type == 'count') { return count($data); } if ($type == 'all') { return parent::_findAll($data, compact('limit', 'page')); } }
/** * find all revisions and return contents of read. * type: all, count, array() * * @param string $type * @param array $options * @return array */ function find($type = 'all', $options = array()) { if ($type == 'branches') { $result = $this->run('branch -a', null, 'capture'); $branches = array(); foreach ($result as $branch) { if (strpos($branch, 'remotes/') !== false || strpos($branch, 'origin/') !== false) { continue; } if ($branch[0] == '*' || $branch[0] == ' ') { $branches[] = trim(substr($branch, 1)); continue; } } return $branches; } if (is_array($type)) { $options = $type; $type = 'first'; } $options = array_merge(array('conditions' => array(), 'fields' => null, 'hash' => null, 'path' => '.', 'order' => 'desc', 'limit' => 100, 'page' => 1), $options); if (!empty($options['revision'])) { $options['hash'] = $options['revision']; unset($options['revision']); } list($options['fields'], $format) = $this->__fields($options['fields']); if ($type == 'first') { $data = $this->run('log', array($options['hash'], $format, '-1')); if (!empty($data)) { return array_combine($options['fields'], array_filter(explode(chr(0), $data))); } return $data; } if (empty($options['path'])) { return false; } $branch = null; if (!empty($options['branch'])) { $branch = $options['branch'] . ' '; } $data = $this->__data; if (empty($data)) { $data = explode("\n", trim($this->run('log', array_merge($options['conditions'], array("{$branch}--pretty=format:%H", '--', str_replace($this->working . '/', '', $options['path'])))))); $this->__data = $data; } if ($type == 'count') { return count($data); } if ($type == 'all') { $this->__data = array(); return parent::_findAll($data, $options); } }