From b05f20ffe45fe2bea2f955bb4d318b86f7bc2f9b Mon Sep 17 00:00:00 2001 From: Bill Peck Date: Fri, 8 May 2015 09:46:49 -0400 Subject: Keep track of dirty repo on our own. If repo has no HEAD is_dirty will throw a traceback. --- git_taskrepo/sub_commands/cmd_init.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'git_taskrepo/sub_commands/cmd_init.py') diff --git a/git_taskrepo/sub_commands/cmd_init.py b/git_taskrepo/sub_commands/cmd_init.py index 2a2ea27..f866a7f 100644 --- a/git_taskrepo/sub_commands/cmd_init.py +++ b/git_taskrepo/sub_commands/cmd_init.py @@ -71,21 +71,24 @@ class Init(Command): cur.execute("INSERT INTO config(origin) VALUES (?)", (remote,)) index = self.repo.index + is_dirty = False # Add taskrepo.db to .gitignore gitignore = "%s/.gitignore" % self.repo.working_tree_dir if update_file(gitignore, "taskrepo.db"): print(" - Added taskrepo.db to .gitignore") index.add([gitignore]) + is_dirty = True # Add testinfo.desc to .gitignore gitignore = "%s/.gitignore" % self.repo.working_tree_dir if update_file(gitignore, "testinfo.desc"): print(" - Added testinfo.desc to .gitignore") index.add([gitignore]) + is_dirty = True # if we updated the repo then commit it - if self.repo.is_dirty(working_tree=False): + if is_dirty: assert index.commit("Initialized to use git taskrepo.").type == 'commit' print(" - committed to git") -- cgit