Created
July 12, 2016 06:49
-
-
Save kristofmeixner/bac394c035b0a98b338202d3e8705768 to your computer and use it in GitHub Desktop.
Saving query files in the queries branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git git = new Git(repository); | |
String pid = query.getPid().getIdentifier(); | |
PersonIdent personIdent = new PersonIdent("Jane Doe","[email protected]"); | |
String message = "Created query file for PID=" + pid; | |
// Building the SHA1 hash for the PID | |
String fileName = DigestUtils.sha1Hex(pid) + ".query"; | |
// Retrieving the queries branch | |
git.checkout().setName("refs/heads/queries").call(); | |
Path filePath = Paths.get(getWorkingTreeDir(), fileName); | |
Properties properties = writeQueryToProperties(query); | |
properties.store(Files.newBufferedWriter(filePath), ""); | |
// Adding the metadata file to the repository | |
git.add().addFilepattern(fileName).call(); | |
// Committing the metadata file | |
git.commit().setMessage(message).setAuthor(personIdent).call(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment