Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose via SVN different branches of a GitLab repo? #188

Closed
db4 opened this issue Sep 10, 2018 · 8 comments · Fixed by #272
Closed

Expose via SVN different branches of a GitLab repo? #188

db4 opened this issue Sep 10, 2018 · 8 comments · Fixed by #272
Labels

Comments

@db4
Copy link

db4 commented Sep 10, 2018

I know git-as-svn does not support (yet) multiple SVN branches layout; this issue recommends

create many svn-repositories for one git-repositry (one repo per branch)

as a workaround. Is it possible for GitLab repos? If yes, can you share an example config doing that?

@slonopotamus
Copy link
Collaborator

No, it is currently impossible to expose multiple branches of a single repo when using !gitlabMapping.

@db4
Copy link
Author

db4 commented Sep 18, 2018

Can you recommend any workaround? I would shutdown a remaining svn repo and move to git completely but svn users need to access multiple branches.

@slonopotamus
Copy link
Collaborator

Multiple branches per repo are currently only supported for repositoryMapping: !listMapping.

However, listMapping

  1. Doesn't support auto-discovery of newly-created repositories/branches and requires manual config editing and git-as-svn restart when repository list changes.
  2. Doesn't support checking user access rights via GitLab, you'll need to specify ACL directly in git-as-svn config. See repositoryMapping section in https://github.com/bozaro/git-as-svn/blob/master/cfg/config-local.example

@db4
Copy link
Author

db4 commented Sep 28, 2018

I've finally found some time to try this approach out. Unfortunately it's not going to work with GitLab-hosted repos. Here is a my config:

repositoryMapping: !listMapping
  repositories:
    test-master:
      access: !acl
        groups:
          - name: developers
            users:
              - test
        access:
          - path: /
            allowed:
              - '@developers'
      repository: !git
        pusher: !pushEmbedded
          update: update
          preReceive: pre-receive
          postReceive: post-receive
        createMode: EXAMPLE
        branch: master
        path: /var/opt/gitlab/git-data/repositories/test/test.git
        renameDetection: true

    test-branch:
      access: !acl
        groups:
          - name: developers
            users:
              - test
        access:
          - path: /
            allowed:
              - '@developers'
      repository: !git
        pusher: !pushEmbedded
          update: update
          preReceive: pre-receive
          postReceive: post-receive
        createMode: EXAMPLE
        branch: branches/branch
        path: /var/opt/gitlab/git-data/repositories/test/test.git
        renameDetection: true

userDB: !gitlabUsers {}

This way I was able to checkout the repo via SVN, but when I try commit something it fails with

Transmitting file data .done
Committing transaction...
svn: E165001: Commit failed (details follow):
svn: E165001: svn: E165001: Hook /var/opt/gitlab/git-data/repositories/test/test.git/hooks/pre-receive failed with output:
GitLab: The project you were looking for could not be found.

Probably, there is something special in GitLab hooks (some env vars should be set?). Any thoughts on how to make it work?

@slonopotamus
Copy link
Collaborator

slonopotamus commented Sep 28, 2018

Aaargh, this is all so weird. GitLab became stupid around 10.x (issue #160) and stopped being able to understand what repo commits are being pushed into (even though hook actually has this information via GIT_DIR environment variable and working directory). So GitLab now needs an environment variable with repo id for that. But we only do that for repositoryMapping: !gitlabMapping because otherwise it isn't clear where we get repository id from :(

createMode: EXAMPLE

Be careful with this, it wipes stuff.

@db4
Copy link
Author

db4 commented Sep 28, 2018

Aaargh, this is all so weird. GitLab became stupid around 10.x (issue #160) and stopped being able to understand what repo commits are being pushed into (even though hook actually has this information via GIT_DIR environment variable and working directory). So GitLab now needs an environment variable with repo id for that. But we only do that for repositoryMapping: !gitlabMapping because otherwise it isn't clear where we get repository id from :(

Thanks for clarifying. Then maybe to add env node to pusher (or repository) config that would allow to set arbitrary environment variables before invoking git? One could set GIT_DIR manually then. I think it should be relatively easy to implement.

createMode: EXAMPLE

Be careful with this, it wipes stuff.

Thanks. I just took this from the example config.

@slonopotamus
Copy link
Collaborator

No, that will not work. Besides repo id GitLab needs user id (because they need to know WHO is pushing to repo and whether he has rights to do so). Uh. I guess we need to go back to !gitlabMapping path and figure out how to handle branches. We'd need a webhook to handle branch creation/deletion events from gitlab, some kind of filtering on what branches to expose, iterate over available branches on startup (because things could change in repo while git-as-svn is offline), etc.

slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Oct 3, 2018
slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Oct 4, 2018
slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Oct 4, 2018
slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Apr 9, 2019
slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Jul 4, 2019
slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Jul 4, 2019
slonopotamus added a commit to slonopotamus/git-as-svn that referenced this issue Jul 4, 2019
@slonopotamus
Copy link
Collaborator

slonopotamus commented Jul 4, 2019

This was fixed in #272 and released in git-as-svn 1.18.0.

Now you just need to add git-as-svn:<branchname> topics to GitLab projects to expose them via git-as-svn.

@slonopotamus slonopotamus added the gitlab GitLab integration label Jul 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants