My remote repository got a tag moved to a new commit.
I run:
git.fetch().setTagOpt(TagOpt.FETCH_TAGS)
.setRemote("remoteURL")
.setRefSpecs(new RefSpec("+refs/heads/*:refs/remotes/origin/*"))
.call();
FetchResult includes a REJECTED update.
The equivalent cli git -t ... does not behave this way.
Don't want to argue cli vs JGit, but wonder how I can do a fetch to update tags?
Seems I have to get org.eclipse.jgit.storage.file.RefUpdate with force=true, but don't know how... and don't realy want to duplicate all FetchProcess code :'(
This was a known problem that was fixed in JGit 3.0, see bug 388095.
As for a solution that works with the earlier releases, adding an explicit refspec for tags helps:
+refs/tags/*:refs/tags/*
Related
I'm writing an utility in swing that show all my projects and should let me clone a specific repo and also select the branch I want to switch to, once the cloning process is finished.
The only problem is that in order to show the branches as far as I can see you need to clone the repo first.
Is there a workaround for that?
You can list tags/heads on remote repositories via the following snippet:
Collection<Ref> refs = Git.lsRemoteRepository()
.setHeads(true)
.setTags(true)
.setRemote(REMOTE_URL)
.call();
See also this ready-to-run snippet in the jgit-cookbook
I'm a bit of a newbie, but already running apps with Meteor.js. Since I'm now working with API keys I'm finally realizing that security is a thing, and so I placed my keys in a settings.json, and am instructed not to commit, or to .gitignore the file. But despite reading the documentation, this all seems very counter-intuitive. If I need the variables to make my HTTP requests, then how can my app possibly function without adding my keys, in some form, to the repo? I know the answer is "it can," but how? (in general terms, I don't need a Meteor specialist yet) .
Typing this question out makes me feel pretty ignorant for the stage I'm at, but the docs out there for some reason are not clarifying this for me.
You can generate the file with sensitive information on git checkout.
That is called a smudge script, part of a content filter driver, using using .gitattributes declaration.
(image from "Customizing Git - Git Attributes", from "Pro Git book")
That 'smudge' script( that you have to write) would need to:
fetch the right key (from a source outside the repo, that way no risk to add and push by mistake)
generate the settings.json, using a tracked manifest template settings.json.tpl with placeholder value in it to replace.
That means:
the template settings.json.tpl is added to the git repo
the generate file settings.json is declared in the .gitignore file and never versioned.
I use Flyway's migrate when I start my application to, well, migrate the database. As per default validateOnMigrate is enabled and validate reports an error if a already applied file is changed.
So far so good, but it seems to ignore cases where an already applied file is missing.
Secondly, if the schema contains a migration that is newer than the latest available, migrate logs a warning but doesn't fail either, for example:
Schema xxx has a version (1.1.1) that is newer than the latest
available migration (1.0.1) !
Is there a way to prevent this behaviour? I would like to have options like failIfMigrationIsMissing and failIfSchemaIsNewer.
All of this would be useful to make sure nobody installs or starts an older version on top of a newer database, e.g. downgrades. Actually I thought this would be the default behaviour, or do I miss something here?
Here's a scheme that works with flyway 4.0.3. You can check all the migrations if your versioning is more complex.
flyway.migrate();
MigrationInfoService migrationInfoService = flyway.info();
MigrationInfo[] applied = migrationInfoService.applied();
MigrationInfo last = applied[applied.length - 1];
if (MigrationState.FUTURE_SUCCESS.equals(last.getState())) {
throw new Exception("Database downgrade detected.");
}
Attempting to use JGit to checkout an existing tag on an existing repository. Preferably left in a headless state. The command should be as simple as:
git checkout clever-tag-name
However, the JGit incantation:
String tagName = "clever-tag-name";
Git.open(new File(repoPath)).checkout().setName(tagName).call();
Results in a series of checkout errors. This usage seems like it should be trivial. The command line version has no issues given my repo's current state.
Here's an example of the checkout error I am referring to:
Exception in thread "main" org.eclipse.jgit.api.errors.CheckoutConflictException: Checkout conflict with files:
.idea/copyright/profiles_settings.xml
...
at org.eclipse.jgit.dircache.DirCacheCheckout.doCheckout(DirCacheCheckout.java:416)
at org.eclipse.jgit.dircache.DirCacheCheckout.checkout(DirCacheCheckout.java:397)
at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:261)
... 6 more
Any help would be greatly appreciated.
The problem is that when i try to update the service reference i get the following error.
The checkout was cancelled by the user.(0x80004004)
I can't seem to do anything that will solve it since if i do try to do something then i have problem with pending changes.
When you Update Service References, changes are made to files in ProjectDirectory/Service References/Your Service Namespace.
These files aren't shown in the solution explorer, but they should be in source control so other team members don't have to manually update references.
Try checking out these files and updating again.