Fetch the file names with status from the commit.

@param string        $commitId The commit identifier.
@param GitRepository $git      The git repository.

@return string
1704
private function fetchNameStatusFromCommit($commitId, GitRepository $git)
    {
        $arguments = [
            $git->getConfig()->getGitExecutablePath(),
            'show',
            $commitId,
            '-M',
            '--name-status',
            '--format='
        ];

        // git show $commitId -M --name-status --format=''
        return $this->runCustomGit($arguments, $git);
    }
1175640
public function getCommitsSince(string $revision) : array
    {
        $cmd = (new Commits($this->repo->getRoot()))->byRevision($revision)
                                                    ->prettyFormat(Commits\Jsonized::FORMAT);

        $result = $this->runner->run($cmd, new Commits\Jsonized());
        return $result->getFormattedOutput();
    }
35872
def get_commit_log(name, vendor='pypi', functions={}, _depth=0):
    
    if "find_changelogs" not in functions:
        from .finder import find_git_repo
        functions["find_changelogs"] = find_git_repo
    if "get_content" not in functions:
        functions["get_content"] = clone_repo
    if "parse" not in functions:
        from .parser import parse_commit_log
        functions["parse"] = parse_commit_log
    return get(
        name=name,
        vendor=vendor,
        functions=functions
    )
17998
def get_oldest_filename(self):
        '''
        
        '''
        commit_and_name_iter = self.git.get_commits_and_names_iter(
            self.content.source_path)
        _commit, name = next(commit_and_name_iter)
        return name
547960
private function fetchAllFilesUnderGit()
  {
    $command = "git ls-files";
    exec($command, $output, $return);
    if ($return!=0) $this->logError("Can not execute command %s in exec", $command);

    foreach ($output as $filename)
    {
      $this->myLastCommitTimes[$filename] = 0;
    }
  }
161327
public List<GitlabCommitDiff> getCommitDiffs(Serializable projectId, String commitHash) throws IOException {
        return getCommitDiffs(projectId, commitHash, new Pagination());
    }
672580
public function getCommits()
    {
        $log = $this->execute(
            "git log --no-merges --format='changeset: %H%nuser: %aN <%aE>%ndate: %ad%nsummary: %s%n' "
            . $this->repository_path
        );
        $this->repository_type = 'git';

        return $this->parseLog($log);
    }
1212635
public function import(GitRepositoryEntity $gitRepository)
    {
        $importer = $this->app->make(TranslatableImporter::class);
        $fetcher = $this->app->make(Fetcher::class, ['gitRepository' => $gitRepository]);
        $packagesRepo = $this->app->make(PackageRepository::class);
        $package = $packagesRepo->findOneBy(['handle' => $gitRepository->getPackageHandle()]);
        if ($package === null) {
            if ($this->logger !== null) {
                $this->logger->notice(t('Creating new package with handle %s', $gitRepository->getPackageHandle()));
            }
            $package = PackageEntity::create($gitRepository->getPackageHandle());
            $this->em->persist($package);
            $this->em->flush($package);
        }
        if ($this->logger !== null) {
            $this->logger->debug(t('Cloning/fetching repository'));
        }
        $fetcher->update();
        if ($this->logger !== null) {
            $this->logger->debug(t('Listing tags'));
        }
        $taggedVersions = $fetcher->getTaggedVersions();
        foreach ($taggedVersions as $tag => $version) {
            if ($gitRepository->getDetectedVersion($version) === null) {
                $gitRepository->addDetectedVersion($version, 'tag', $tag);
                $this->em->persist($gitRepository);
                $this->em->flush($gitRepository);
            }
            $packageVersion = null;
            foreach ($package->getVersions() as $pv) {
                if ($pv->getVersion() === $version) {
                    $packageVersion = $pv;
                    break;
                }
            }
            if ($packageVersion === null) {
                if ($this->logger !== null) {
                    $this->logger->debug(t('Checking out tag %s', $tag, $version));
                }
                $fetcher->switchToTag($tag);
                if ($this->logger !== null) {
                    $this->logger->info(t('Extracting strings from tag %1$s for version %2$s', $tag, $version));
                }
                $importer->importDirectory($fetcher->getRootDirectory(), $package->getHandle(), $version, '');
            } else {
                if ($this->logger !== null) {
                    $this->logger->debug(t('Tag already imported: %1$s (version: %2$s)', $tag, $version));
                }
            }
        }
        foreach ($gitRepository->getDevBranches() as $branch => $version) {
            if ($gitRepository->getDetectedVersion($version) === null) {
                $gitRepository->addDetectedVersion($version, 'branch', $branch);
                $this->em->persist($gitRepository);
                $this->em->flush($gitRepository);
            }
            if ($this->logger !== null) {
                $this->logger->debug(t('Checking out development branch %s', $branch));
            }
            $fetcher->switchToBranch($branch);
            if ($this->logger !== null) {
                $this->logger->info(t('Extracting strings from development branch %1$s for version %2$s', $branch, $version));
            }
            $importer->importDirectory($fetcher->getRootDirectory(), $package->getHandle(), $version, '');
        }
    }
231809
def get_changed_files_from(old_commit_sha, new_commit_sha):
        
        return check_output(
            "git diff-tree --no-commit-id --name-only -r {0}..{1}".format(
                old_commit_sha,
                new_commit_sha
            ).split(" ")
            ).decode('utf-8').strip()
59361
public function gitlab($projectId)
    {
        $project = $this->fetchProject($projectId, 'gitlab');

        $payloadString = file_get_contents("php://input");
        $payload = json_decode($payloadString, true);

        // build on merge request events
        if (isset($payload['object_kind']) && $payload['object_kind'] == 'merge_request') {
            $attributes = $payload['object_attributes'];
            if ($attributes['state'] == 'opened' || $attributes['state'] == 'reopened') {
                $branch = $attributes['source_branch'];
                $commit = $attributes['last_commit'];
                $committer = $commit['author']['email'];

                return $this->createBuild($project, $commit['id'], $branch, $committer, $commit['message']);
            }
        }

        // build on push events
        if (isset($payload['commits']) && is_array($payload['commits'])) {
            // If we have a list of commits, then add them all as builds to be tested:

            $results = array();
            $status = 'failed';
            foreach ($payload['commits'] as $commit) {
                try {
                    $branch = str_replace('refs/heads/', '', $payload['ref']);
                    $committer = $commit['author']['email'];
                    $results[$commit['id']] = $this->createBuild(
                        $project,
                        $commit['id'],
                        $branch,
                        $committer,
                        $commit['message']
                    );
                    $status = 'ok';
                } catch (Exception $ex) {
                    $results[$commit['id']] = array('status' => 'failed', 'error' => $ex->getMessage());
                }
            }
            return array('status' => $status, 'commits' => $results);
        }

        return array('status' => 'ignored', 'message' => 'Unusable payload.');
    }
1074285
public function createPullRequestComment($repo, $pullId, $commitId, $file, $line, $comment)
    {
        $token = Config::getInstance()->get('phpci.github.token');

        if (!$token) {
            return null;
        }

        $url = '/repos/' . strtolower($repo) . '/pulls/' . $pullId . '/comments';

        $params = array(
            'body' => $comment,
            'commit_id' => $commitId,
            'path' => $file,
            'position' => $line,
        );

        $http = new HttpClient('https://api.github.com');
        $http->setHeaders(array(
            'Content-Type: application/x-www-form-urlencoded',
            'Authorization: Basic ' . base64_encode($token . ':x-oauth-basic'),
        ));

        $http->post($url, json_encode($params));
    }
1019188
def get_git_info():
    """"""
    start_dir = abspath(curdir)
    try:
        chdir(dirname(abspath(__file__)))
        re_patt_str = (r'commit\s+(?P<commit_hash>\w+).*?Author:\s+'
                       r'(?P<author_name>.*?)\s+<(?P<author_email>.*?)>\s+Date:\s+'
                       r'(?P<date>.*?)\n\s+(?P<commit_msg>.*?)(?:\ndiff.*?)?$')
        show_out = check_output(['git', 'show']).decode('ascii')
        revp_out = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'])
        revp_out = revp_out.decode('ascii').strip()
        m = re.search(re_patt_str, show_out, re.DOTALL)
        assert m is not None, \
            "Regex pattern:\n\n\"%s\"\n\n failed to match string:\n\n\"%s\"" \
            % (re_patt_str, show_out)
        ret_dict = m.groupdict()
        ret_dict['branch_name'] = revp_out
    finally:
        chdir(start_dir)
    return ret_dict
522090
public Iterable<PushResult> pushToRepository(Git git, String remote) {
        try {
            return git.push()
                .setRemote(remote)
                .setPushAll()
                .setPushTags()
                .call();
        } catch (GitAPIException e) {
            throw new IllegalStateException(e);
        }
    }
49027
public function syncFiles($contentId)
    {
        $block = $this->repository->getById($contentId);
        if (empty($block)) {
            return $this->respondNotFound();
        }
        $this->authorize('update', $block);
        $input = $this->validator->validate('syncFiles');
        $block = $this->fileRepository->syncWith($block, $this->buildSyncData($input));
        return $this->respondWithSuccess($block);
    }
1329672
@GET
    @Path("commitTree/{commitId}")
    public List<CommitTreeInfo> getCommitTree(final @PathParam("commitId") String commitId) throws Exception {
        return gitReadOperation(new GitOperation<List<CommitTreeInfo>>() {
            @Override
            public List<CommitTreeInfo> call(Git git, GitContext context) throws Exception {
                return doGetCommitTree(git, commitId);
            }
        });
    }
1071054
async function getRev(rev, currentRev, client, config) {
  var revHash = rev.substr(config.indexKey.indexOf('%s'));
  if (revHash === 'current') return;

  var str = revHash === currentRev ? rev + ' (current)' : rev;
  try {
    const commitData = await gitlog({
      repo: path.resolve(process.cwd(), '.git'),
      number: 1,
      fields: [
        'abbrevHash',
        'subject',
        'committerDate',
        'committerDateRel',
        'authorName',
        'hash',
      ],
      branch: revHash,
    });
    if (!commitData.length) {
      return;
    }

    const firstCommitData = commitData[0];

    const metadata = await client.get(util.format(config.metaKey, revHash));
    if (!metadata) {
      gutil.log(gutil.colors.red('Cannot retrieve metadata'));
      return;
    }

    return [
      new Date(firstCommitData.committerDate),
      gutil.colors.yellow(str),
      firstCommitData.subject,
      gutil.colors.white(firstCommitData.committerDateRel),
      gutil.colors.white.blue('<' + firstCommitData.authorName + '>'),
      (metadata && gutil.colors.white.blue(metadata)) || '',
    ];
  } catch (e) {
    if (e.toString().indexOf('unknown revision') > 0) {
      return [
        0,
        gutil.colors.yellow(str),
        gutil.colors.red('Unknown revision'),
      ];
    }
    gutil.log(gutil.colors.yellow(str));
    gutil.log(gutil.colors.red('Error:'), e);
  }
}
1180423
protected function getCurrentUserInfo($git)
    {
        // Sadly no command in our git library for this.
        $arguments = [
            $git->getConfig()->getGitExecutablePath(),
            'config',
            '--get-regexp',
            'user.[name|email]'
        ];

        $process = new Process($this->prepareProcessArguments($arguments), $git->getRepositoryPath());

        $git->getConfig()->getLogger()->debug(
            \sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine())
        );

        $process->run();
        $output = \rtrim($process->getOutput(), "\r\n");

        if (!$process->isSuccessful()) {
            throw GitException::createFromProcess('Could not execute git command', $process);
        }

        $config = array();
        foreach (\explode(PHP_EOL, $output) as $line) {
            list($name, $value)   = \explode(' ', $line, 2);
            $config[\trim($name)] = \trim($value);
        }

        if (isset($config['user.name']) && $config['user.email']) {
            return \sprintf('%s <%s>', $config['user.name'], $config['user.email']);
        }

        return '';
    }