Refine search
private void addEdge(File edgeDir, File edgeFile, String fileContents) throws IOException, GitAPIException { createNewFile(edgeDir, edgeFile, fileContents); // add, commit, push edge this.gitForPush.add().addFilepattern(formEdgeFilePath(edgeDir.getParentFile().getName(), edgeDir.getName(), edgeFile.getName())).call(); this.gitForPush.commit().setMessage("Edge commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); }
@Signature public void add(String filePattern, ArrayMemory settings) throws GitAPIException { AddCommand addCommand = getWrappedObject().add(); addCommand.addFilepattern(filePattern); if (settings != null && settings.isNotNull()) { addCommand.setUpdate(settings.valueOfIndex("update").toBoolean()); } DirCache dirCache = addCommand.call(); }
public void run() throws Exception { addCommand.addFilepattern(CRUISE_CONFIG_XML).call(); git.commit().setAuthor(rev.getUsername(), STUDIOS_PRODUCT).setMessage(rev.getComment()).call(); } });
try (Git git = new Git(db)) { Repository repo = git.getRepository(); String originalBranch = repo.getFullBranch(); boolean empty = repo.resolve(Constants.HEAD) == null; if (!empty) { if (repo.findRef(branch) == null) git.branchCreate().setName(branch).call(); git.checkout().setName(branch).call(); git.add().addFilepattern(filename).call(); RevCommit commit = git.commit() .setMessage(branch + ": " + filename).call();
result = Git.cloneRepository().setURI(remotePath).setDirectory(new File(localPath)).call(); } catch (Exception e) { LOGGER.error("Error cloning backup git repo"); git = new Git(backupRepo); File myfile = new File(localPath + "/" + fileName); git.add().addFilepattern(".").call(); } catch (GitAPIException e) { LOGGER.error("Error adding files to git"); git.commit().setMessage("Taking backup on " + new Date()).call(); git.close(); if (result != null) result.getRepository().close(); backupRepo.close();
throw ServerLogger.ROOT_LOGGER.failedToPullRepository(ex, gitConfig.getRepository()); if (!this.branch.equals(repository.getBranch())) { addCommand.addFilepattern("data/content/"); Path configurationDir = basePath.resolve("configuration"); try (Stream<Path> files = Files.list(configurationDir)) { files.filter(configFile -> !"logging.properties".equals(configFile.getFileName().toString()) && Files.isRegularFile(configFile)) .forEach(configFile -> addCommand.addFilepattern(getPattern(configFile))); addCommand.call(); createGitIgnore(git, basePath); git.commit().setMessage(ServerLogger.ROOT_LOGGER.repositoryInitialized()).call(); } catch (GitAPIException | IOException ex) { throw ServerLogger.ROOT_LOGGER.failedToInitRepository(ex, gitConfig.getRepository()); StoredConfig config = git.getRepository().getConfig(); config.setString("remote", remoteName, "url", gitConfig.getRepository()); config.setString("remote", remoteName, "fetch", "+" + R_HEADS + "*:" + R_REMOTES + remoteName + "/*"); checkoutToSelectedBranch(git); if (createGitIgnore(git, basePath)) { git.commit().setMessage(ServerLogger.ROOT_LOGGER.addingIgnored()).call();
if (!"master".equalsIgnoreCase(git.getRepository().getBranch())) { git.checkout() .setCreateBranch(true) .setName("master") if (!branch.equalsIgnoreCase(git.getRepository().getBranch())) { boolean create = true; for (Ref ref : git.branchList().call()) { git.add() .addFilepattern(relative) .call(); git.commit() .setAuthor("clement", "clement@apache.org") .setCommitter("clement", "clement@apache.org") .setMessage("Add " + relative) .call();
@Override public void flush(boolean success) { if (success) { try (Git git = gitRepository.getGit()) { Status status = git.status().call(); if (!status.isClean()) { String message = git.getRepository().parseCommit(git.getRepository().resolve(HEAD)).getFullMessage(); if(! status.getUntracked().isEmpty() || ! status.getUntrackedFolders().isEmpty()) { AddCommand addCommand = git.add(); for(String untracked : status.getUntrackedFolders()) { addCommand = addCommand.addFilepattern(untracked); } for(String untracked : status.getUntracked()) { addCommand = addCommand.addFilepattern(untracked); } addCommand.call(); } git.commit().setMessage(message).setAmend(true).setAll(true).setNoVerify(true).call(); } } catch (RevisionSyntaxException | IOException | GitAPIException ex) { throw new RuntimeException(ex); } } }
git = Git.open(gitRepository); File dst = new File(git.getRepository().getWorkTree(), "fabric/profiles"); git.add().addFilepattern(".").call(); for (String missing : git.status().call().getMissing()) { git.commit() .setMessage("Installing profiles from patch \"" + patch.getPatchData().getId() + "\"") .call();
Set<String> changeds = git.status().call().getModified(); if ( changeds.isEmpty() ) AddCommand add = git.add(); for ( String changed : changeds ) add.addFilepattern( changed ); doCommit = true; add.call(); UserInfo committer = getCommitter( repo, git ); CommitCommand command = git.commit().setMessage( message ).setAuthor( author.name, author.email ); command.setCommitter( committer.name, committer.email ); RevCommit commitRev = command.call(); if ( StringUtils.isBlank( branch ) ) branch = git.getRepository().getBranch();
public static void main(String[] args) throws IOException, GitAPIException { final File path; try (Repository repository = CookbookHelper.createNewRepository()) { try (Git git = new Git(repository)) { path = repository.getWorkTree(); System.out.println("Repository at " + path); git.add().addFilepattern("file1.txt").call(); RevCommit rev1 = git.commit().setAuthor("test", "test@test.com").setMessage("Commit Log 1").call(); System.out.println("Rev1: " + rev1); git.add().addFilepattern("file1.txt").call(); RevCommit rev2 = git.commit().setAll(true).setAuthor("test", "test@test.com").setMessage("Commit Log 2").call(); System.out.println("Rev2: " + rev2); git.add().addFilepattern("file1.txt").call(); RevCommit rev3 = git.commit().setAll(true).setAuthor("test", "test@test.com").setMessage("Commit Log 3").call(); System.out.println("Rev3: " + rev3);
localPath = repository.getWorkTree(); try (Git git = new Git(repository)) { File file1 = new File(repository.getDirectory().getParent(), "testfile"); FileUtils.writeStringToFile(file1, "some text", "UTF-8"); File file2 = new File(repository.getDirectory().getParent(), "testfile2"); FileUtils.writeStringToFile(file2, "some text", "UTF-8"); git.add() .addFilepattern("testfile") .call(); git.add() .addFilepattern("testfile2") .call(); git.commit() .setMessage("Added testfiles") .call();
ConcurrentRefUpdateException, WrongRepositoryStateException, AbortedByHookException { checkCallable(); Collections.sort(only); RepositoryState state = repo.getRepositoryState(); if (!state.canCommit()) throw new WrongRepositoryStateException(MessageFormat.format( processOptions(state, rw); if (all && !repo.isBare()) { try (Git git = new Git(repo)) { git.add() .addFilepattern(".") //$NON-NLS-1$ .setUpdate(true).call(); } catch (NoFilepatternException e) { Ref head = repo.exactRef(Constants.HEAD); if (head == null) throw new NoHeadException( try (ObjectInserter odi = repo.newObjectInserter()) { if (!only.isEmpty()) index = createTemporaryIndex(headId, index, rw);
FileUtils.deleteDirectory(new File(git.getRepository().getWorkTree(), managedDirectory)); unpack(baselineDistribution, git.getRepository().getWorkTree(), 1); String fabricVersion = determineVersion(git.getRepository().getWorkTree(), "fabric"); git.add() .addFilepattern(".") .call(); for (String missing : git.status().call().getMissing()) { git.rm().addFilepattern(missing).call(); gitPatchRepository.prepareCommit(git, String.format(MARKER_BASELINE_COMMIT_PATTERN, version)).call(); git.add() .addFilepattern("etc/org.apache.karaf.features.cfg") .call(); gitPatchRepository.prepareCommit(git, String.format(MARKER_BASELINE_REPLACE_PATCH_FEATURE_PATTERN, version, bundleContext.getBundle().getVersion().toString())).call(); resetOverrides(git.getRepository().getWorkTree(), Collections.<String>emptyList()); git.add().addFilepattern("etc/overrides.properties").call(); return gitPatchRepository.prepareCommit(git, String.format(MARKER_BASELINE_RESET_OVERRIDES_PATTERN, version)).call();
protected CommitInfo doCreateDirectory(Git git, File rootDir, String branch, String path, PersonIdent personIdent, String commitMessage) throws Exception { File file = getFile(rootDir, path); if (file.exists()) { return null; } file.mkdirs(); String filePattern = getFilePattern(path); AddCommand add = git.add().addFilepattern(filePattern).addFilepattern("."); add.call(); CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(commitMessage); RevCommit revCommit = commitThenPush(git, branch, commit); return createCommitInfo(revCommit); }
public URI push(File source, String name) throws Exception { init(); File gitRoot = new File("target", name); FileUtils.copyDirectory(source, gitRoot); // Push via port forward String repoUrl = String.format("http://localhost:%s/%s", GIT_LOCALPORT, name); Git git = Git.init().setDirectory(gitRoot).call(); Repository repo = git.getRepository(); repo.getConfig().setString("remote", "origin", "url", repoUrl); repo.getConfig().save(); git.add().addFilepattern(".").call(); git.commit().setMessage("testing").setAuthor("Arquillian", "cube@discuss.arquillian.org").call(); git.push().setRemote("origin").setPushAll().setForce(true).call(); repo.close(); // Return an internal service name, for use within the openshift network String serverUrl = String.format("http://%s:%s/%s", GIT_SERVICE, GIT_REMOTEPORT, name); return URI.create(serverUrl); }
private void addSubmodule(String name, String url, String path, String revision, List<CopyFile> copyfiles, List<LinkFile> linkfiles, Git git) throws GitAPIException, IOException { assert (!repo.isBare()); assert (git != null); if (!linkfiles.isEmpty()) { throw new UnsupportedOperationException( JGitText.get().nonBareLinkFilesNotSupported); } SubmoduleAddCommand add = git.submoduleAdd().setName(name).setPath(path) .setURI(url); if (monitor != null) add.setProgressMonitor(monitor); Repository subRepo = add.call(); if (revision != null) { try (Git sub = new Git(subRepo)) { sub.checkout().setName(findRef(revision, subRepo)).call(); } subRepo.close(); git.add().addFilepattern(path).call(); } for (CopyFile copyfile : copyfiles) { copyfile.copy(); git.add().addFilepattern(copyfile.dest).call(); } }
remoteRepo.create(true); Git gitForPush = Git.cloneRepository().setURI(remoteRepo.getDirectory().getAbsolutePath()).setDirectory(cloneDir).call(); gitForPush.commit().setMessage("First commit").call(); RefSpec masterRefSpec = new RefSpec("master"); gitForPush.push().setRemote("origin").setRefSpecs(masterRefSpec).call(); + ConfigurationKeys.GIT_MONITOR_REPO_URI, remoteRepo.getDirectory().getAbsolutePath()) .addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TESTDIR + "/git-flowgraph") .addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5) gitForPush.add().addFilepattern(formNodeFilePath(flowGraphDir, nodeDir.getName(), nodeFile.getName())).call(); gitForPush.commit().setMessage("Node commit").call(); gitForPush.push().setRemote("origin").setRefSpecs(masterRefSpec).call();
if (fork.getRepository().getRef("refs/heads/" + gitPatchRepository.getFuseSSHContainerPatchBranchName()) == null) { String startPoint = "patch-management^{commit}"; if (fork.getRepository().getRef("refs/remotes/origin/" + gitPatchRepository.getFuseSSHContainerPatchBranchName()) != null) { startPoint = "refs/remotes/origin/" + gitPatchRepository.getFuseSSHContainerPatchBranchName(); .call(); if (fork.getRepository().getRef("refs/heads/" + gitPatchRepository.getFabric8SSHContainerPatchBranchName()) == null) { String startPoint = "patch-management^{commit}"; if (fork.getRepository().getRef("refs/remotes/origin/" + gitPatchRepository.getFabric8SSHContainerPatchBranchName()) != null) { fork.add() .addFilepattern(".") .call(); RevCommit commit = gitPatchRepository.prepareCommit(fork, String.format(MARKER_BASELINE_SSH_COMMIT_PATTERN, tagName, fabric8Version)) .call(); fork.tag()
private static void checkoutExistingBranchOrCreateOrphan(Git git, boolean isLocalOnly, String username, String password, String branch) throws IOException, GitAPIException { if (!isLocalOnly) { fetch(git, username, password); } // need to checkout branch ? if (!branch.equals(git.getRepository().getBranch())) { // HEAD is needed for creating a branch try { git.log().setMaxCount(1).call(); } catch (NoHeadException e) { // no HEAD - commit for creating a HEAD git.add().addFilepattern(".").call(); git.commit().setCommitter("a4c-bot", "a4c-bot@robot.org").setMessage("initial commit").call(); } // checkout branch CheckoutCommand checkoutCommand = git.checkout(); checkoutCommand.setName(branch); if (!branchExistsLocally(git, branch)) { checkoutCommand.setCreateBranch(true); String fullReference = getFullBranchReference(git, branch); boolean existRemotely = !fullReference.isEmpty(); if (existRemotely) { checkoutCommand.setStartPoint(getFullBranchReference(git, branch)); } else { checkoutCommand.setOrphan(true); } } checkoutCommand.call(); } }