class JGitSourceReferencesProvider implements SourceReferencesProvider {

    @Override
    public String getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl) throws MojoExecutionException {
        File basedir = project.getBasedir().getAbsoluteFile();
        FileRepositoryBuilder builder = new FileRepositoryBuilder().readEnvironment().findGitDir(basedir)
                .setMustExist(true);
        Repository repo;
        Git git;
        try {
            repo = builder.build();
            git = Git.wrap(repo);
        } catch (IOException e) {
            throw new MojoExecutionException("IO exception trying to create git repo ", e);
        }
        ObjectId head = resolveHead(repo);

        StringBuilder result = new StringBuilder(scmUrl.getUrl());
        result.append(";path=\"");
        result.append(getRelativePath(basedir, repo.getWorkTree()));
        result.append("\"");

        String tag = findTagForHead(git, head);
        if (tag != null) {
            // may contain e.g. spaces, so we quote it
            result.append(";tag=\"");
            result.append(tag);
            result.append("\"");
        }
        result.append(";commitId=");
        result.append(head.getName());
        return result.toString();
    }

}