PEP8 and cosmetic changes.
This commit is contained in:
parent
7413926589
commit
526ed05c41
@ -16,11 +16,13 @@ GITIGNORE = """# files or directories for the git plugin to ignore
|
||||
|
||||
|
||||
class GitPlugin(PapersPlugin):
|
||||
"""The git plugin creates a git repository in the pubs directory and commit the changes
|
||||
to the pubs repository everytime a paper is modified.
|
||||
"""Make the pubs repository also a git repository.
|
||||
|
||||
It also add the `pubs git` subcommand, so git commands can be executed in the git repository
|
||||
from the command line.
|
||||
The git plugin creates a git repository in the pubs directory
|
||||
and commit the changes to the pubs repository.
|
||||
|
||||
It also add the `pubs git` subcommand, so git commands can be executed
|
||||
in the git repository from the command line.
|
||||
"""
|
||||
|
||||
name = 'git'
|
||||
@ -72,17 +74,18 @@ class GitPlugin(PapersPlugin):
|
||||
"""
|
||||
colorize = ' -c color.ui=always' if self.force_color else ''
|
||||
git_cmd = 'git -C {}{} {}'.format(self.pubsdir, colorize, cmd)
|
||||
#print(git_cmd)
|
||||
p = Popen(git_cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, shell=True)
|
||||
output, err = p.communicate(input_stdin)
|
||||
p.wait()
|
||||
|
||||
if p.returncode != 0:
|
||||
raise RuntimeError('The git plugin encountered an error when running the git command:\n' +
|
||||
'{}\n\nReturned output:\n{}\n'.format(git_cmd, output.decode('utf-8')) +
|
||||
'If needed, you may fix the state of the {} git repository '.format(self.pubsdir) +
|
||||
'manually.\nIf relevant, you may submit a bug report at ' +
|
||||
'https://github.com/pubs/pubs/issues')
|
||||
raise RuntimeError((
|
||||
'The git plugin encountered an error when running the git command:\n'
|
||||
'{}\n\n'
|
||||
'Returned output:\n{}\n'
|
||||
'If needed, you may fix the state of the {} git repository manually.\n'
|
||||
'If relevant, you may submit a bug report at https://github.com/pubs/pubs/issues'
|
||||
).format(git_cmd, output.decode('utf-8'), self.pubsdir))
|
||||
elif command:
|
||||
self.ui.message(output.decode('utf-8'), end='')
|
||||
elif not self.quiet:
|
||||
@ -97,10 +100,11 @@ def paper_change_event(event):
|
||||
git = GitPlugin.get_instance()
|
||||
if not git.manual:
|
||||
event_desc = event.description
|
||||
for a, b in [('\\','\\\\'), ('"','\\"'), ('$','\\$'), ('`','\\`')]:
|
||||
for a, b in [('\\', '\\\\'), ('"', '\\"'), ('$', '\\$'), ('`', '\\`')]:
|
||||
event_desc = event_desc.replace(a, b)
|
||||
git.list_of_changes.append(event_desc)
|
||||
|
||||
|
||||
@PostCommandEvent.listen()
|
||||
def git_commit(event):
|
||||
if GitPlugin.is_loaded():
|
||||
|
@ -31,7 +31,7 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
||||
self.execute_cmds([('pubs rename Page99a ABC',)])
|
||||
hash_c = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds([('pubs remove ABC', ['y']),])
|
||||
self.execute_cmds([('pubs remove ABC', ['y'])])
|
||||
hash_d = git_hash(self.default_pubs_dir)
|
||||
|
||||
self.execute_cmds([('pubs doc add testrepo/doc/Page99.pdf Page99',)])
|
||||
@ -101,6 +101,5 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
||||
self.assertNotEqual(hash_l, hash_m)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user