RepositoryService { public String getLastSha(Project project) { Repo repo = new Repo(project.getName(), project.getRepository(), project.getRef()); REPOS.computeIfAbsent(repo, key -> checkoutRepository(key)); Path path = REPOS.get(repo); synchronized (path) { checkoutRevision(path, project.getRef(), "HEAD"); return commandService.invoke(path, "git", "log", "--pretty=format:%H", "-1"); } }  @PreDestroy void cleanup(); String getLastMessage(Project project, String sha); String getLastSha(Project project); void checkoutRepository(Project project); InputStream getFile(Build build, String filePath);  }
@Test public void shouldGetLastSha() throws IOException { Project project = getProject(); String lastSha = service.getLastSha(project); assertThat(lastSha).isNotEmpty(); }