translate / pootle_fs_git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tries to pull instead of clone after switching a project from localfs to git

LarsMichelsen opened this issue · comments

commented

I had setup a pootle server with 2.8* and created a project using localfs. I wanted to use the git fs backend, so I updated pootle to 2.9 and setup the git plugin (will send you a required pull request later).

After configuring the git fs backend, I tried to fetch the data from the git server like this:

pootle fs -v 3 fetch my_project
2017-12-01 09:34:17,085 INFO Pulling git repository(my_project): ssh://lm@host/my_project
Traceback (most recent call last):
  File "/home/pootle/pootle/env/bin/pootle", line 11, in <module>
    sys.exit(main())
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/pootle/runner.py", line 365, in main
    run_app(project='pootle', django_settings_module='pootle.settings')
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/pootle/runner.py", line 346, in run_app
    management.execute_from_command_line(command)
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/pootle/core/management/subcommands.py", line 164, in run_from_argv
    return self.subcommands[known.subcommand]().run_from_argv(argv)
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/pootle/apps/pootle_fs/management/commands/fs_commands/fetch.py", line 16, in handle
    self.get_fs(options["project"]).fetch()
  File "/home/pootle/pootle/env/src/pootle-fs-git/pootle_fs_git/plugin.py", line 129, in fetch
    self.repo.remote().pull("master:master", force=True)
  File "/home/pootle/pootle/env/src/pootle-fs-git/pootle_fs_git/plugin.py", line 113, in repo
    return Repo(self.project.local_fs_path)
  File "/home/pootle/pootle/env/local/lib/python2.7/site-packages/git/repo/base.py", line 156, in __init__
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: /home/pootle/pootle/env/local/lib/python2.7/site-packages/pootle/.pootle_fs/tmp/my_project

After looking at plugin.py it seems that the self.is_cloned option was set to True which made the plugin try to pull instead of clone.

I just removed the directory /home/pootle/pootle/env/local/lib/python2.7/site-packages/pootle/.pootle_fs/tmp/my_project and retried the fetch operation. Now the plugin is trying to clone.

Seems the detection which operation is needed should be improved. For example try to detect whether or not there is a cloned repo inside.

There may be ways to do this using the python git module. Otherwise possibly simply check for ".git" directory existance?