GitUtils { public File findWorkingDirectory(Project project) { if (currentlyRunningOnTravisCi()) { return new File(System.getenv("TRAVIS_BUILD_DIR")); } else if (currentlyRunningOnGithubActions()) { return new File(System.getenv("GITHUB_WORKSPACE")); } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.workingDir(project.getProjectDir()); execSpec.commandLine("git", "rev-parse", "--show-toplevel"); execSpec.setStandardOutput(outputStream); execSpec.setIgnoreExitValue(true); }); if (execResult.getExitValue() == 0) { return new File(outputStream.toString().trim()); } else { return null; } }  static boolean currentlyRunningOnTravisCi(); static boolean currentlyRunningOnGithubActions(); @Nullable static String findSlug(Project project); @Nullable String findTravisSlug(Project project); String getRemoteUrl(Project project, String remote); File findWorkingDirectory(Project project); String getTag(Project project); @Nullable String findGithubUsername(Project project); @Nullable String findGithubToken(Project project);  }
@Test void findWorkingDirectory() { assertThat(GitUtils.findWorkingDirectory(project)).isNotNull(); }