test_class.file: tycho-extras/tycho-sourceref-jgit/src/test/java/org/eclipse/tycho/extras/sourceref/jgit/JGitSourceReferencesProviderTest.java
test_class.identifier: JGitSourceReferencesProviderTest
test_case.body: @Test
      public void testGetSourceReferencesHeader() throws MojoExecutionException {
          JGitSourceReferencesProvider provider = new JGitSourceReferencesProvider();
          MavenProject mockProject = new MavenProject();
          ScmUrl scmUrl = new ScmUrl(properties("scm:git:foo"));
          mockProject.setFile(new File("src/test/resources/pom.xml").getAbsoluteFile());
          String sourceRef = provider.getSourceReferencesHeader(mockProject, scmUrl);
          assertTrue(sourceRef.startsWith("scm:git:foo;path=\"tycho-extras/tycho-sourceref-jgit/src/test/resources\""));
      }
test_case.class_method_signature: JGitSourceReferencesProviderTest.testGetSourceReferencesHeader()
test_case.full_signature: @Test public void testGetSourceReferencesHeader()
test_case.identifier: testGetSourceReferencesHeader
test_case.invocations: properties setFile getAbsoluteFile getSourceReferencesHeader assertTrue startsWith
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetSourceReferencesHeader()
focal_class.file: tycho-extras/tycho-sourceref-jgit/src/main/java/org/eclipse/tycho/extras/sourceref/jgit/JGitSourceReferencesProvider.java
focal_class.identifier: JGitSourceReferencesProvider
focal_class.interfaces: implements SourceReferencesProvider
focal_class.class_method_signature: JGitSourceReferencesProvider.getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl)
focal_class.full_signature: @Override public String getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl)
focal_class.identifier: getSourceReferencesHeader
focal_class.modifiers: @Override public
focal_class.parameters: (MavenProject project, ScmUrl scmUrl)
focal_class.return: String
focal_class.signature: String getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl)
focal_class.class_method_signature: JGitSourceReferencesProvider.resolveHead(Repository repo)
focal_class.full_signature: private ObjectId resolveHead(Repository repo)
focal_class.identifier: resolveHead
focal_class.modifiers: private
focal_class.parameters: (Repository repo)
focal_class.return: ObjectId
focal_class.signature: ObjectId resolveHead(Repository repo)
focal_class.class_method_signature: JGitSourceReferencesProvider.findTagForHead(Git git, ObjectId head)
focal_class.full_signature: private String findTagForHead(Git git, ObjectId head)
focal_class.identifier: findTagForHead
focal_class.modifiers: private
focal_class.parameters: (Git git, ObjectId head)
focal_class.return: String
focal_class.signature: String findTagForHead(Git git, ObjectId head)
focal_class.class_method_signature: JGitSourceReferencesProvider.getRelativePath(File subDir, File parentDir)
focal_class.full_signature:  String getRelativePath(File subDir, File parentDir)
focal_class.identifier: getRelativePath
focal_class.parameters: (File subDir, File parentDir)
focal_class.return: String
focal_class.signature: String getRelativePath(File subDir, File parentDir)
focal_method.body: @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();
      }
focal_method.class_method_signature: JGitSourceReferencesProvider.getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl)
focal_method.full_signature: @Override public String getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl)
focal_method.identifier: getSourceReferencesHeader
focal_method.invocations: getAbsoluteFile getBasedir setMustExist findGitDir readEnvironment build wrap resolveHead getUrl append append getRelativePath getWorkTree append findTagForHead append append append append append getName toString
focal_method.modifiers: @Override public
focal_method.parameters: (MavenProject project, ScmUrl scmUrl)
focal_method.return: String
focal_method.signature: String getSourceReferencesHeader(MavenProject project, ScmUrl scmUrl)