jgit | Git version control system in pure Java
kandi X-RAY | jgit Summary
kandi X-RAY | jgit Summary
An implementation of the Git version control system in pure Java. This package is licensed under the EDL (Eclipse Distribution License). JGit can be imported straight into Eclipse, built and tested from there, but the automated builds use Maven.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Runs the job
- Parses the line range option
- Abbreviates the given commit
- Compute range
- Convert a glob pattern to a Java regular expression
- Checks if the char class is a valid POSIX char class
- Sets the char in the buffer
- Executes a git commit
- Utility method to stash the contents
- Executes the ApplyPatch command
- Executes the remote command
- Attempts to delete a branch
- Drops a configuration ref from the stash
- Renames a branch
- Parse the body of the script
- Run the walk
- Perform a recursive scan
- Creates a new Git repository
- Rebuilds all objects
- Run the delete
- Create a password authentication
- Performs a recursive scan
- Perform the merge operation
- Executes the revert command
- Rename the log
- Compute the next commit
jgit Key Features
jgit Examples and Code Snippets
Community Discussions
Trending Discussions on jgit
QUESTION
This is regarding a Spring Cloud Config Server hobby project (with @EnableConfigServer
).
Yesterday, the application could be started.
Today, the application failed to start because of a Git communication error.
From GitHub's official blog post, it is mentioned that SHA-1 is no longer supported starting from 15 March 2022. And that explains the results I'm getting these 2 days.
March 15, 2022
Changes made permanent.
We’ll permanently stop accepting DSA keys. RSA keys uploaded after the cut-off point above will work only with SHA-2 signatures (but again, RSA keys uploaded before this date will continue to work with SHA-1). The deprecated MACs, ciphers, and unencrypted Git protocol will be permanently disabled.
Even if I didn't delete the existing SSH key, it still failed to start today. But anyway, now the only key under the "Deploy keys" section of the repository settings is an SSH key that was added after the March 15, 2022 cut off date.
Dependency versionsDependency Management:
Dependency Version spring-cloud-dependencies Hoxton.SR12Dependency:
Dependency Version spring-cloud-config-server (Managed) Spring application configurationsapplication.yml
:
ANSWER
Answered 2022-Mar-16 at 14:07I have a same problem.
See https://github.com/spring-cloud/spring-cloud-config/issues/2061
For right now, I have a dirty workaround: use https uri, username and password(maybe personal secret token).
QUESTION
I downloaded the sample code from GitHub and modified the ReadNodeExample.java just to make sure that I can connect to an OPC Server (not Milo, it's a C#-based OPC Server). I was able to verify that the sample code is able to read/write/call nodes from my server with the modifications.
I then reimplemented what I thought I needed into my actual project, but I might be missing something since I cannot connect under this project and receive the following error:
java.lang.NoSuchMethodError: 'io.netty.buffer.ByteBuf io.netty.buffer.ByteBuf.writeMediumLE(int)'
This error happens in the ClientExampleRunner.run() while running createClient() I can still run the sample project and still connects.
Here's my pom.xml: The org.milo is added near the end and I added what I saw was added from the sample (included ch.qos.logback and jetbrains). Then added the io.netty thinking it would help, but still have the same error.
...ANSWER
Answered 2022-Mar-21 at 22:29It seems that your actual project has an old version of Netty somewhere on its classpath.
ByteBuf::writeMediumLE
(and all the other LE
-suffixed ByteBuf
methods) were introduced in Netty 4.1.
QUESTION
In 2022, GitHub has discontinued DSA and RSA with old signatures.
Unfortunately, JGit uses JSch which is not getting any updates and will always offer old signatures with RSA even for "good" keys, and its implementation of ECDSA/ed25519 will fail on reconnect attempt.
Is JGit usable with GitHub at all - what kind of configuration should I use? I am talking about a combination of key type, configuration settings and code invocations that would lead to reliable work against GitHub.
...ANSWER
Answered 2022-Mar-18 at 21:11There is a fork of JSch which has support for modern algorithms and should be fairly robust. I know of at least one major organization using it against GitHub with success.
However, note that it disables RSA with SHA-1 support by default, because it's insecure (which is why GitHub is phasing it out), so if you need to work with sites that don't support anything else (e.g., Azure DevOps at the moment), you'll need to set some configuration accordingly.
You may also be able to use Apache Mina in conjunction with JGit. The 5.13 release of JGit supports Mina 2.7.0, which should support modern algorithms.
QUESTION
GitHub has engaged its 2nd phase of SSH protocol security, where they disable using SHA-1 with RSA keys. The OpenSSH client works OK with the RSA keys, but the org.jgit
one inside TeamCity is working no longer, getting:
Failed to collect changes, error: org.eclipse.jgit.errors.NoRemoteRepositoryException: git@github.com:Project/Repository.git: ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
How do I instruct TeamCity not using SHA-1 and using supported hashing instead?
I could possibly migrate to Ed25519 key, but it is not supported by our Windows agents, and I have to change all keys in the TeamCity once more, meaning I will have two problems.
Is there a practical way to make TeamCity friends with SSH RSA keys for GitHub in 2022? For reference, I am on 2021.2.1
.
ANSWER
Answered 2022-Mar-18 at 19:39TeamCity now has versions out that properly work with RSA key using SHA-512, which GitHub will accept. Older version of TeamCity prefers ssh-rsa
over rsa-sha2-512
and rsa-sha2-256
, unlike most other clients, so they will always try to log in with the insecure SHA-1-based RSA signatures when using an RSA key and get this message. OpenSSH prefers the SHA-2-based signatures first, and so it works.
If you use the latest version, 2021.2.3, or newer, then you should be able to use an RSA key without problems. Ed25519 keys or ECDSA keys may also be able to work properly, although older versions may also have bugs in them.
QUESTION
I have a Github workflow which is configured to trigger on tag push event:
...ANSWER
Answered 2022-Mar-06 at 17:22The answer is to use PAT - Personal Access Token for this action instead of GITHUB_TOKEN.
Here you can find more details:
If you do want to trigger a workflow from within a workflow run, you can use a personal access token instead of GITHUB_TOKEN to trigger events that require a token. You'll need to create a personal access token and store it as a secret
QUESTION
I'm playing around with the scala-forklift
library and wanted to test an idea by modifying the code in the library and example project.
This is how the project is structured:
/build.sbt
-> Contains definition ofscala-forklift-slick
project (including its dependencies) in the form of:
ANSWER
Answered 2022-Feb-27 at 18:25Luis Miguel Mejía Suárez's comment worked perfectly and was the easier approach.
In the context of this project, all I had to do was:
- Append
-SNAPSHOT
to the version in/version.sbt
(should not be needed normally but for this project I had to do this) - Run
sbt publishLocal
in the parent project.
After this, the example project (which already targets the -SNAPSHOT
version) is able to pick up the locally built package.
QUESTION
I am trying to create a remote branch with jgit, which executes exactly the following git commands:
- git clone git@gitlab.com:my-project/test.git
- git checkout -b superBranch
- git push --set-upstream origin superBranch
After these executions, I can change and push the files of the branch without merge request.
jGit:
Unfortunately jgit does not know the command "push -u" (Upstream). So I found some maybe solution. But all solutions does not work really.
First in StackOverflow:
...ANSWER
Answered 2021-Nov-27 at 17:36Following code works for me:
QUESTION
We are configuring spring cloud config server and below is how my application properties look:
...ANSWER
Answered 2022-Jan-04 at 15:06The use of username and password to do git operations on GitHub is deprecated and it no longer works, as described here.
You should generate a Personal Access Token, follow the official documentation to do it. Then you can add the token to the spring configuration as it was you password:
QUESTION
In JGit, is it possible to check developer permissions without doing the actions (provided username and password)?
Ex: Is it possible to check if a user can clone a repository without cloning it?
Ex2: Is it possible to check if a user can push to a repository without pushing to it?
...ANSWER
Answered 2022-Jan-04 at 11:28I think, this is not supported by git
itself, so no. (I might be wrong though)
As a workaround, one might use CloneCommand#setNoCheckout(boolean)
[1], which prevents downloading any branch (clone command should be pretty quick). The cloned repository (cloned into some temp directory), might be removed immediately, if call succeeded.
For push, dry-run
can be used. Supported by JGit [2].
Most of the commands have some form of dry-run
option.
See: Do all git commands have a dry-run option?
--
QUESTION
I see issues in the Spring cloud config server (Springboot) logs when connecting to the repo where configs are stored. I'm not sure if it's unable to clone because of credentials or something else (git-upload-pack not permitted). Any pointers to this would be great.
...ANSWER
Answered 2021-Oct-28 at 00:08Github token needs to be passed as username which I was configuring against the password property for the spring boot app. The password property needs to be left empty and the Github-token needs to be assigned to the username like below-
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
Install jgit
You can use jgit like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the jgit component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page