def test_empty(self): porcelain.commit(repo=self.repo.path, message=b'test status', author=b'', committer=b'') f = StringIO() porcelain.ls_tree(self.repo, b"HEAD", outstream=f) self.assertEqual(f.getvalue(), "")
def test_simple(self): # Commit a dummy file then modify it fullpath = os.path.join(self.repo.path, "foo") with open(fullpath, "w") as f: f.write("origstuff") porcelain.add(repo=self.repo.path, paths=["foo"]) porcelain.commit(repo=self.repo.path, message=b"test status", author=b"", committer=b"") f = StringIO() porcelain.ls_tree(self.repo, b"HEAD", outstream=f) self.assertEqual(f.getvalue(), "100644 blob 8b82634d7eae019850bb883f06abf428c58bc9aa\tfoo\n")
def run(self, args): parser = optparse.OptionParser() parser.add_option("-r", "--recursive", action="store_true", help="Recusively list tree contents.") parser.add_option("--name-only", action="store_true", help="Only display name.") options, args = parser.parse_args(args) try: treeish = args.pop(0) except IndexError: treeish = None porcelain.ls_tree( '.', treeish, outstream=sys.stdout, recursive=options.recursive, name_only=options.name_only)
def test_simple(self): # Commit a dummy file then modify it fullpath = os.path.join(self.repo.path, 'foo') with open(fullpath, 'w') as f: f.write('origstuff') porcelain.add(repo=self.repo.path, paths=['foo']) porcelain.commit(repo=self.repo.path, message=b'test status', author=b'', committer=b'') f = StringIO() porcelain.ls_tree(self.repo, b"HEAD", outstream=f) self.assertEqual( f.getvalue(), '100644 blob 8b82634d7eae019850bb883f06abf428c58bc9aa\tfoo\n')
scriptDir = sys.path[0] repoPath = os.path.abspath(os.path.join(scriptDir, '..', '..', REPOSITORY)) print >> sys.stderr, "repo path: " + str(repoPath) try: #try to run a command if command == "init": porcelain.init(repoPath) porcelain.show(repoPath) with open(repoPath + '/.gitignore', 'w') as f: f.write('local/\n') f.write('*.sw?\n') f.close elif command == "ls": print "x,type,hash,path" porcelain.ls_tree(repoPath) #orcelain.show('..') elif command == "add": if paths == '': porcelain.add(repoPath) # file(s) to add, defaults to app name else: porcelain.add(repoPath, paths) print "next steps:\nrun '|git status' to show what is ready to commit etc and '|git commit' to commit" elif command == "commit": """ def commit(repo='.', message=None, author=None, committer=None): Create a new commit. Parameters repo Path to repository message Optional commit message author Optional author name and email committer Optional committer name and email