Use JGit to rename the repository - rename

I'm developing a tool that has 3 functions as follows:
Create a Git repository.
Delete a Git repository.
Rename a Git repository.
I must use JGit to implement this tool. But I did not find a way to rename of the repository by using JGit.
Does anyone know how to use JGit to rename the repository?

A Git repository does not have a name in itself, hence JGit does not provide an API for renaming.
Usually the last segment of the directly in which the repository is located is used to name it when necessary. For example a repository in /foo/bar/.git will be named bar.
In order to rename a repository, simply move its location by using the Java file API.

Related

Access files from different git repository

I want to separate out some files to a another git repository so that different projects can use it. These files contains some common functions that can be used by different projects in gitlab.
How can I access the newly created 'common' repository in my existing project?
Sample code:
file generate.py contents: *import common_xyz
def using_common_xyz: do something...*
I have now moved the file containing common_xyz to a different repository. I read that we can use "Include" keyword in .gitlab-ci.yml to access files in other repository. Or should I treat them as library? Can anyone suggest what is the best way?
Git submodules would be the way to go.
From git-scm.com:
Submodules allow you to keep a Git repository as a subdirectory of
another Git repository. This lets you clone another repository into
your project and keep your commits separate.
Here's a cool guide (theserverside.com) to get started using both GitHub and GitLab.
Here's another, on git-scm.com

being in one GIT repository, is it possible to add/commit/push files to another GIT repository using nodejs

I have lot of files coming from S3 and I want to add/commit/push those files to one new GIT repository using nodejs. Being in one repository can we push files to another repository? if possible, please let me know how to do that.

Share one file across multiple git repo to be updated by multiple users

I am working on automating the markdown spell check for all the documents on my website which involves multiple git repo. I have a .spelling file that contains all the word to be excluded from the documents. I would like to keep it one file and updated across the entire website. I can get it to work for one repo. I looked into the npm package method. Is there a way to configure package.json to share this file to many repo? Or is there a better way to do it without npm? Thanks!
Make a separate spell-check repository with the .spelling file and script in it, then include it as a submodule in each of your docs repos. You can then reference it from each repository separately, and pull its latest updates into each one.
This could be cumbersome if you have a large number of docs repos, so another alternative is to centralize the spelling check script by making a separate repository for it and adding a configuration file to tell your script which Github repositories to spellcheck. This way, you can selectively apply the spell check process to any number of repositories in your organization.

How do I properly deal with a symlink folder when using Subversion?

I want to add my project to a subversion repository. The project folder contains a symlink to a folder containing thousands of txt files that I don't need to add to the svn repository. I DO want the symlink-folder to show up when I checkout the code, however.
It looks like I can use svn addprop svn:ignore symlinked-folder to ignore the folder, but then I'll have to add that symlinked folder to every working copy I check out before everything will work.
Is there a proper way to do this?
Perhaps there is no way to deal with this, since a symlink is a filesystem artifact. Is there a better way to handle this situation?
CONCLUSION - EDIT
After all this investigation, I committed the symlink-folder by accident and SVN added it to the repository without adding any of the files within it. Upon checkout, everything works fine. The symlink-folder checked out and works.
I am using assembla to manage my SVN repository, so that might have something to do with this success.
The answers above are right, your symlink won't work if you check out the repository on windows.
But if you're aware of that and you don't care, you can add just the symlink without its contents:
svn add -N your-symlink
man svn add here
I believe you are correct, imagine if a user checked out your repo under Windows - how would SVN create the symlink when the underlying OS doesn't support it?
Is the target folder that you are symlinking to under version control? If so, you can make use of the svn-externals property.
You are right, it doesn't make sense to add a symlink to a repository. What would happen if someone checked out the source on a machine that didn't have access to the folder the symlink points to?
One way is to structure your repository so that you can check out the codebase without having to check out documents. E.g.:
Trunk
Tags
Branches
Documents
So you only check out the trunk or branch that you are working on, and when you require it you can check out the documents.
Alternatively, use a project management tool like Redmine to store your docs. It can integrate with svn as well so you can view your repository and manage permissions through it.

Importing a Mercurial repository automatically (e.g. SVN Externals)

I have a project that I am developing built off CodeIgniter. The main part of the project is a private system I am creating, but I want to add it to source control, to gain all the associated goodies. Now I'm using Mercurial, so I did the whole hg init bit, so I've got the repository set up.
Now, one of the things I've done is to make a library for CodeIgniter, which I use in this project. Now I want to make this library open, so I need a separate repo for that.
For anyone unfamiliar with CodeIgniter library development, here's a reference:
application
/config <- configuration files
/libraries <- library logic in here
Now I will probably develop a few more libraries in the course of this project, so I can't just dump a repo in the application folder without clumping them all together.
What I did was this:
dev/ci/library <- library here
dev/project <- project here
Now in both of those folders, I have made a repository. What I want to do is make the project repository automatically reference the library repository, so I can have a private and a public repository, as I explained earlier.
The main way to do this, I have read, is to use subrepositories, but I can only find examples on nested ones (which are unclear anyway, I find). How do I make it reference another repository like svn:externals?
You are correct, subrepos in Mercurial (or submodules in Git) are based on a nested organization.
But in your specific case you need:
two separate repos,
not nested
A way to reconcile both organizations (yours and the nested "subrepo") would be to have three repos
a parent repo (private one, as in can be pushed to a private repo)
the project (private one, as in can be pushed to a private repo)
the library (public one, as in can be pushed to a public repo)
That would give the following:
/dev
.hg (private repo)
.hgsubs (declare the two nested repos 'project' and 'ci/library')
project
.hg (private repo for your project)
config
.hgignore (for ignoring anyhting from libraries)
libraries (private directory, not version)
(symlink to /dev/ci/library)
ci
library
.hg (public repo
That way, you keep:
your two repo separate as you want
a link between the two in order to be able to get back those two repo at the exact reference you left them (i.e. you last pushed each of those repos).
Implemented in Mercurial 1.3, here's the instructions.

Resources