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