-
-
Notifications
You must be signed in to change notification settings - Fork 933
origin.refs always '[]' #652
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
Comments
I cannot reproduce this issue. Can you provide a self-sustaining script that can? |
thanks reply, It's work now, version GitPython==2.1.7, close this issue plz, Thank you again. |
Hi.. I'm having the same issue here: When cloning: repo = git.Repo("my-awesome-project-folder")
o = repo.remotes.origin It breaks into this error: 2020-04-07 11:53:12,844 - ERROR - 'IterableList' object has no attribute 'origin' And when I tried to do something with the origin url, it fails also: try
repo = git.Repo("my-awesome-project-folder")
origin = repo.remote('origin')
except Exception as e:
logger.error(e) And breaks into Exception: 2020-04-07 11:53:12,892 - ERROR - Remote named 'origin' didn't exist The proyect has a remote and is called origin. Actually, a tried to create it but I doesnt let me to do it, because origin already exists. $ git --version
git version 1.8.3.1 $ pip freeze
GitPython==3.0.0 I've been working with my script tons of times before. I manage the repo for my organization, around 700 differents repos. I have this problem with only one project. Really strange behavior. I hope this comment help to find the bug. |
Thanks for the detailed information, @panterozo . Maybe you will be able to use the debugging tips to get down to the bottom of this. Thanks so much for your consideration. |
Hi again.. I have being monitoring this behavior, and some times works and some times doesnt. About a previous ask #910 (comment), the anwser is this:
Its seems exactly as you described before. Another think... I enabled debug mode and I could get some differences, bewteen one project that works and one that doesnt. This Works
This Doesnt Work
The only different lines is The complete secuence of my code is as follow: from git import Repo
import git
def cargarPipeline(self):
error=""
try:
repo2 = self.cloneRepo(self.getProjectObject().http_url_to_repo,self.getNombre())
if isinstance(repo2, str):
if repo2 == "":
raise ValueError("An error has occurs by cloning the project '%s' " % self.getNombre())
elif repo2.startswith('Error:'):
raise ValueError(repo2)
# Change the controller from Repo to GitPython
repo = git.Repo("./projectsGit/"+self.getNombre())
try:
repo.git.checkout('Desarrollo-CI')
except Exception as e:
logger.error(e)
raise ValueError("Error changing branch 'Desarrollo-CI' for loading pipeline file to project '%s' " % self.getNombre())
commit_message = 'pipeline: the pipeline was updated'
if self.getTipoProyecto() == "apps":
shutil.copy2('./projectsGit/pipelines/.gitlab-ci-Apps.yml', "./projectsGit/"+self.getNombre()+'/.gitlab-ci.yml')
commit_message += " apps"
else:
shutil.copy2('./projectsGit/pipelines/.gitlab-ci-Microservicios.yml', "./projectsGit/"+self.getNombre()+'/.gitlab-ci.yml')
commit_message += " ms"
file_list = [
".gitlab-ci.yml"
]
repo.index.add(file_list)
repo.index.commit(commit_message)
origin = repo.remote('origin')
origin.push()
except Exception as e:
logger.error(e)
error="Error: 1" + str(e)
else:
logger.info("The pipeline for '%s' project was successfully updated" % self.getNombre())
pass
finally:
return error This program is use for uploading a new version of pipeline .gitlab-ci.yml. Maybe, when I change the controller could breaks something?. The clone function is as follow def cloneRepo(self, cloneURL, projectName):
repo=""
try:
# Se asocia token
url = cloneURL.replace("https://","https://gitlab-ci-token:<token>")
if os.path.exists("./projectsGit/"+projectName):
repo = git.Repo("./projectsGit/"+projectName)
o = repo.remotes.origin
o.pull()
else:
repo = Repo.clone_from(url, "./projectsGit/"+projectName)
except Exception as e:
logger.error(e)
error="Error: " + str(e)
else:
logger.info("The project '%s' has been cloned" % projectName)
pass
finally:
return repo Im looking forward, Thanks |
@panterozo Thanks for posting, I reopened the issue in the hopes for someone to look into it! |
Hi @Byron.. Thanks by your consern. That token wasn't real. It was put there only to understand what was happening. |
I've had the "Remote named 'origin' didn't exist" error an it was caused by the directory path containing some characters that GitPython didn't like.
I don't understand much about your particular issue, but thought this could help. |
Indeed, GitPython has great issues handling paths due to the way Python handles encodings. Maybe there is a working way of doing that these days, but if so |
Hi, when I call |
I'm seeing the same behavior. |
The cause for me ended up being that repo had been cloned with |
set this doc: http://gitpython.readthedocs.io/en/stable/tutorial.html#handling-remotes
origin.refs equals []
so
origin.refs.master
this will raise error: AttributeError: 'IterableList' object has no attribute 'origin/master'The text was updated successfully, but these errors were encountered: