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

The remote directory isn't correctly added #2

Open
gcetusic opened this issue Sep 11, 2013 · 2 comments
Open

The remote directory isn't correctly added #2

gcetusic opened this issue Sep 11, 2013 · 2 comments

Comments

@gcetusic
Copy link

Let's say we have a remote repository https://github.com/user/repo.git and it wasn't added to local git remote list. The following code should create the repository if 'git ls-remote' fails

try:
    subprocess.check_call(['git', 'ls-remote', git_repository])
except subprocess.CalledProcessError:
    try:
        subprocess.check_call(['git', 'remote', 'add', 'po_translator', git_repository])
    except subprocess.CalledProcessError as e:
        raise PODocsError(e)

Bit if the public key is set correctly, running 'git ls-remote [email protected]:user/repo.git' doesn't cause an exception and, later, the code fails because the repo po_translator doesn't exist.

@stefan8
Copy link
Collaborator

stefan8 commented Sep 11, 2013

You are right. I suggest checking existing remote by remote show po_translator.

try:
    subprocess.check_call(['git', 'remote', 'show', '-n', 'po_translator'])
except subprocess.CalledProcessError:
    try:
        subprocess.check_call(['git', 'remote', 'add', 'po_translator', git_repository])
    except subprocess.CalledProcessError as e:
        raise PODocsError(e)

What do you think about this?
I can see problem when someone change git_repository in config, should we check if it's still the same? But probably it's not common case.

@gcetusic
Copy link
Author

I ran into this problem using django-c3po so I'll give my opinion from that perspective. Since django-c3po has a setting GIT_REPOSITORY that's used when calling git_push, I think users expect THAT repository to be used. I'm guessing django-c3po users have no idea what exactly git_push does, shouldn't be bothered with git configuration beyond settings and C3PO should override .git/config since it added it in the first place so "remote show" line should be evicted entirely. Could you please review #3 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants