с помощью модуля gitpython я пишу скрипт Python для проверки git diff --> git add всех измененных файлов один за другим. В конце я хочу зафиксировать все эти изменения, но не нашел точного синтаксиса команды.
Я пытаюсь использовать приведенный ниже код: 'git add ' работает отлично, но 'git commit' выдает ошибку.
import git
repo = git.Repo(os.getcwd())
files = repo.git.diff(None, name_only=True)
for f in files.split('\n'):
show_diff(f)
repo.git.add(f)
repo.git.commit('test commit', author='sunilt@xxx.com')
Вот какую ошибку я вижу: кажется, в аргументах cmd чего-то не хватает.
In [10]: repo.git.commit("test commit", author="sunilt@xxx.com")
---------------------------------------------------------------------------
GitCommandError Traceback (most recent call last)
in ()
----> 1 repo.git.commit("test commit", author="sunil.thorat@nuance.com")
c:\python27\lib\site-packages\git\cmd.pyc in (*args, **kwargs)
421 if name[0] == '_':
422 return LazyMixin.__getattr__(self, name)
--> 423 return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
424
425 def set_persistent_git_options(self, **kwargs):
c:\python27\lib\site-packages\git\cmd.pyc in _call_process(self, method, *args, **kwargs)
866 call.extend(args)
867
--> 868 return self.execute(call, **_kwargs)
869
870 def _parse_object_header(self, header_line):
c:\python27\lib\site-packages\git\cmd.pyc in execute(self, command, istream, with_extended_output, with_exceptions, as_process, output_stream, stdout_as_string, kill_after_timeout, with_stdout, universal_newlines, shell, **subprocess_kwargs)
684
685 if with_exceptions and status != 0:
--> 686 raise GitCommandError(command, status, stderr_value, stdout_value)
687
688 if isinstance(stdout_value, bytes) and stdout_as_string: # could also be output_stream
GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git commit --author=sunilt@xxx.com test commit
stderr: 'error: pathspec 'test commit' did not match any file(s) known to git.'
Подробнее здесь: https://stackoverflow.com/questions/406 ... git-commit
Gitpython: синтаксис команды для git commit ⇐ Python
Программы на Python
-
Anonymous
1736414362
Anonymous
с помощью модуля [b]gitpython[/b] я пишу скрипт Python для проверки git diff --> git add всех измененных файлов один за другим. В конце я хочу зафиксировать все эти изменения, но не нашел точного синтаксиса команды.
Я пытаюсь использовать приведенный ниже код: 'git add ' работает отлично, но 'git commit' выдает ошибку.
import git
repo = git.Repo(os.getcwd())
files = repo.git.diff(None, name_only=True)
for f in files.split('\n'):
show_diff(f)
repo.git.add(f)
repo.git.commit('test commit', author='sunilt@xxx.com')
Вот какую ошибку я вижу: кажется, в аргументах cmd чего-то не хватает.
In [10]: repo.git.commit("test commit", author="sunilt@xxx.com")
---------------------------------------------------------------------------
GitCommandError Traceback (most recent call last)
in ()
----> 1 repo.git.commit("test commit", author="sunil.thorat@nuance.com")
c:\python27\lib\site-packages\git\cmd.pyc in (*args, **kwargs)
421 if name[0] == '_':
422 return LazyMixin.__getattr__(self, name)
--> 423 return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
424
425 def set_persistent_git_options(self, **kwargs):
c:\python27\lib\site-packages\git\cmd.pyc in _call_process(self, method, *args, **kwargs)
866 call.extend(args)
867
--> 868 return self.execute(call, **_kwargs)
869
870 def _parse_object_header(self, header_line):
c:\python27\lib\site-packages\git\cmd.pyc in execute(self, command, istream, with_extended_output, with_exceptions, as_process, output_stream, stdout_as_string, kill_after_timeout, with_stdout, universal_newlines, shell, **subprocess_kwargs)
684
685 if with_exceptions and status != 0:
--> 686 raise GitCommandError(command, status, stderr_value, stdout_value)
687
688 if isinstance(stdout_value, bytes) and stdout_as_string: # could also be output_stream
GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git commit --author=sunilt@xxx.com test commit
stderr: 'error: pathspec 'test commit' did not match any file(s) known to git.'
Подробнее здесь: [url]https://stackoverflow.com/questions/40633097/gitpython-command-syntax-for-git-commit[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия