wellington-junio / gitblit

Automatically exported from code.google.com/p/gitblit
Apache License 2.0
0 stars 0 forks source link

Create new repositories as --shared #263

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When creating a new repository or forking a repository, the repo is created as 
--bare, but not as --shared.

Personally I think all server hosted repos should be created with --shared, 
i.e. g+s permissions under Unix. But it would be nice if we could at least have 
an option to set when creating a new repository if it should be created as if 
created with git init --bare --shared.

This would make it easier to use Gitblit in an environment where repository 
access is not exclusively through Gitblit but Gitblit is rather used as an 
add-on to manage repositories.

Original issue reported on code.google.com by f.zscho...@gmail.com on 2 Jul 2013 at 3:32

GoogleCodeExporter commented 9 years ago
Unfortunately, as far as I can see JGit does not (yet) support --shared.

Original comment by James.Mo...@gmail.com on 2 Jul 2013 at 3:57

GoogleCodeExporter commented 9 years ago
So, do you think you could work around that by directly setting the config 
variable "core.sharedRepository" and maybe even "receive.denyNonFastForwards" 
with JGit Config methods?

Original comment by f.zscho...@gmail.com on 3 Jul 2013 at 12:52

GoogleCodeExporter commented 9 years ago
Yes, I can manipulate the repo config and I can use JNA to workaround Java 6 
limitations in setting unix filesystem permissions to emulate what you 
describe, but I'm not comfortable making this change for the next release which 
should be out in a day or two.

If you need this now then I recommend creating the repos from outside Gitblit 
and clearing Gitblit's cache afterwards so that it sees your new repo(s).

You want --shared because you are cloning/pushing these repos with file:// 
urls, right?

BTW, while I can set "receive.denyNonFastForwards" for other Git tooling, 
Gitblit does not respect this setting.

Original comment by James.Mo...@gmail.com on 3 Jul 2013 at 1:32

GoogleCodeExporter commented 9 years ago
No, I want shared because I use Gitblit for creating/forking repositories but 
not as the exclusive access control tool. Access is also through Apache and via 
SSH. So all repositories are owned by the git group and g+s. 

Original comment by f.zscho...@gmail.com on 3 Jul 2013 at 1:45

GoogleCodeExporter commented 9 years ago
James, could you give me some pointers to the code I should be looking at in 
order to "manipulate the repo config" and "use JNA to workaround Java 6 
limitations in setting unix filesystem permissions"? I would like to start 
working on this as it is my next most pressing issue for our installation.

Original comment by f.zscho...@gmail.com on 12 Aug 2013 at 6:12

GoogleCodeExporter commented 9 years ago
JNA is already a dependency so this should be less painful.

Below is half of what you want - setting the sharedRepository flag - and a hint 
on how to do the remainder.  The linked CLibrary api may not be the correct 
one.  The basic plan is to set the repo config and file system permissions 
after the repository is init'd, since JGit doesn't support --shared.

JGitUtils.createRepository() {
  try {
    Git git = Git.init().setDirectory(new File(repositoriesFolder, name)).setBare(true).call();
    boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") > -1;
    if (!isWindows) {
      StoredConfig config = git.getRepository().getConfig();
      config.setBoolean("core", null, "sharedRepository", true);
      config.save();

      // JNA here
      // http://stackoverflow.com/a/664453/830200
    }
    return git.getRepository();
  } catch (IOException e) {
    throw new RuntimeException(e);
  } catch (GitAPIException e) {
    throw new RuntimeException(e);
  }
}

Original comment by James.Mo...@gmail.com on 12 Aug 2013 at 6:44

GoogleCodeExporter commented 9 years ago
Merged to master

Original comment by James.Mo...@gmail.com on 17 Sep 2013 at 9:57

GoogleCodeExporter commented 9 years ago
1.4.0 released.

Original comment by James.Mo...@gmail.com on 9 Mar 2014 at 6:06