i want to get the changes of a source file with the git command git log -S'hello world'.
It works, but I don't know how to do the same with JGit. The JGit LogCommand has no such option -S.
Here’s a quick example of how to get some log messages:
Git git = new Git(db);
Iterable<RevCommit> log = git.log().call();
UPDATE
Please try to use a modified version of the JGitUtils from the great http://gitblit.com/:
Look at the source of the method getFilesInCommit to see how this can work (PathChangeModel is just used to hold the data.)
also try to read from this tutorial about gitlog in JGIT and dont forget to check properties of gitlog
https://wiki.eclipse.org/JGit/User_Guide#LogCommand_.28git-log.29
Related
import { exec } from "https://deno.land/x/exec/mod.ts";
await exec(`git clone https://github.com/vuejs/vue.git`)
when i use git clone https://github.com/vuejs/vue.git in .sh file, It has message in terminal,
but don't have in deno
First, I think it is important to echo what jsejcksn commented:
The exec module is not related to Deno. All modules at https://deno.land/x/... are third-party code. For working with your shell, see Creating a subprocess in the manual.
Deno's way of doing this without a 3rd party library is to use Deno.run.
With that said, if you take a look at exec's README you'll find documentation for what you're looking for under Capture the output of an external command:
Sometimes you need to capture the output of a command. For example, I do this to get git log checksums:
import { exec } from "https://deno.land/x/exec/mod.ts";
let response = await exec('git log -1 --format=%H', {output: OutputMode.Capture});
If you look at exec's code you'll find it uses Deno.run under the hoods. If you like exec you can use it but you might find you like using Deno.run directly instead.
I had a repository named tags, I renamed it to tag.
I then created a new repository named tags (the old name of the first one).
Now when commiting from R Studio both projects try to commit to the same repository (tags).
I initiated my projects with :
shell("git remote add origin https://github.com/moodymudskipper/tag.git", intern = TRUE)
shell("git push -u origin master",intern = TRUE)
and
shell("git remote add origin https://github.com/moodymudskipper/tags.git",intern = TRUE)
shell("git push -u origin master",intern = TRUE)
And after this I only committed through Rstudio's API and usethis functions, I don't know much more than that about git.
Links to the packages :
https://github.com/moodymudskipper/tag
https://github.com/moodymudskipper/tags
How can I sort this out ?
I'm hesitant to throw this out as an answer, but: you can manually edit the ./.git/config file to update the [remote ...] section to change the remote URL. I have done this confidently enough with an empty repo ...
Check for presence of the tag with grep -rli tags.git .git/*; if all you get is .git/config, then you're good to edit and move on. If you find other files, though, I don't know for certain that they will be updated as you continue with your git remote work. In that case, it might be helpful to look at https://help.github.com/en/articles/changing-a-remotes-url in order to formally change the URL.
I am building a small tool to propose some Git commands to users not familiar with Git. The commands are not intended to modify the repo, just consult some information.
I am creating the tool in Java, using JGit which seems to be the best match to do this kind of stuff.
The issue I face so far is that I create a temporary folder to host the repo content, but I am unable to delete it automatically at the end of the execution.
Here is the code (I removed the try/catch stuff to simplify the reading):
// Create temporary folder
Path folderPath = Paths.get(System.getProperty("user.dir"));
File localRepoFolder = Files.createTempDirectory(folderPath, "local-repo").toFile();
// Clone the repo
CloneCommand clone = new CloneCommand();
clone.setURI("https://myrepo");
clone.setNoCheckout(true);
clone.setDirectory(localRepoFolder);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider("user", "password"));
Git gitRepo = clone.call();
// Do some stuff
[...]
// Cleanup before closing
gitRepo.getRepository().close();
gitRepo.close();
localRepoFolder.deleteOnExit();
I searched quite a lot on this topic, but I get everywhere that it should be automatically deleted... Am I missing something?
I would use something like Apache Commons IO (http://commons.apache.org/proper/commons-io/) which has a FileUtils.deleteDirectory
As per this https://hackpad.com/Migrating-Packages-zN0we9sIjkH I created a new meteor package and currently facing a problem when trying to publish.
PackageName : 'UserId:packageName'
To add package : 'meteor add packageName' (mateor add UserId:packageName did not work).
Package runs locally without any issue.
When I tried to publish,
cd path/to/your:package
meteor publish
Message :
There is no package named 'packageName'. If you are creating a new package, use the --create flag.
Publish failed.
Then I tried "meteor publish --create"
Message :
To confirm that you wish to create a top-level package with no account
prefix, please run this command again with the --top-level option.
(Only administrators can create top-level packages without an account prefix)
I used "UserId: PackageName" when creating the package and already log in to meteor account. Any idea to fix this issue?
Thanks !
Make sure the name field is in package.js:
Package.describe({
name: "user:packagename",
// other fields
});
Then, there will be no need to make sure the package is in a directory with the same name.
See https://github.com/mizzao/meteor-user-status for an example.
We are using git to maintain our source. URL like git#xx.xx.xx.xx:XYZ.git. I'm using JGit to pull the changes.
UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider("xxxx", "xxxx");
localPath = "E:\\murugan\\Test\\GIT_LOCALDEPY";
Git git = new Git(localRepo);
PullCommand pcmd = git.pull();
pcmd.setCredentialsProvider(user);
pcmd.call();
I'm getting the following exception when I execute the code.
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git#xx.xx.xx.xx:22:
org.eclipse.jgit.transport.CredentialItem$StringType:Passphrase for C:\Users\Murugan.SOLVER\.ssh\id_rsa
If username/password security is not an issue, you can specify the credentials as part of the connection in the .git/config file of the local Git repo:
[remote "origin"]
url = ssh://<user>:<pwd>#<host>:22/<remote-path-to-repo>/
fetch = +refs/heads/*:refs/remotes/origin/*
You have to configure your SSH parameters on your machine before using Git. Here is a link, from github, for configuring it.
https://help.github.com/categories/56/articles
especially this one: https://help.github.com/articles/generating-ssh-keys
This will help you set up everything properly (you should adapt everything, since you are probably not connecting to GitHub)