def test_some(self): cid = porcelain.commit(repo=self.repo.path, message=b'test status', author=b'', committer=b'') self.assertEqual({ b'refs/heads/master': cid, b'HEAD': cid}, porcelain.ls_remote(self.repo.path))
def run(self, args): opts, args = getopt(args, '', []) if len(args) < 1: print('Usage: dulwich ls-remote URL') sys.exit(1) refs = porcelain.ls_remote(args[0]) for ref in sorted(refs): sys.stdout.write("%s\t%s\n" % (ref, refs[ref]))
def test_empty(self): self.assertEqual({}, porcelain.ls_remote(self.repo.path))
def _are_local_and_remote_heads_different(self): local_head = Repo(self.cached_repo).head() remote_head = git.ls_remote(self.remote_url)[b"HEAD"] return local_head != remote_head
elif command == "ls-tree": try: treeish = sys.argv[2] except IndexError: treeish = 'HEAD' # fallback to HEAD print treeish porcelain.ls_tree(repoPath, treeish) elif command == "fetch": """ def fetch(repo, remote_location, outstream=sys.stdout, errstream=default_bytes_err_stream): """ print >> sys.stderr, "handle command fetch" porcelain.fetch(repoPath, remote) elif command == "ls-remote": print >> sys.stderr, "handle command ls-remote" porcelain.ls_remote(remote) elif command == "remote": print >> sys.stderr, "handle command remote" try: verb = sys.argv[2] if verb == "add": """ def remote_add(repo, name, url): Add a remote. :param repo: Path to the repository :param name: Remote name :param url: Remote URL """ porcelain.remote_add(repoPath, sys.argv[3], sys.argv[4]) except IndexError:
def check_update(): data = {} repo = Repo('.') local_ref = repo.head().decode('utf-8') print('Versão local: ', local_ref) remote_commit = porcelain.ls_remote(REMOTE_REPO)[b"HEAD"].decode('utf-8') print('\nVersão remota: ', remote_commit) with porcelain.open_repo_closing(repo) as r: walker = r.get_walker(max_entries=1) for entry in walker: message = str(entry.commit.message)[2:-3] author = str(entry.commit.author) if message.startswith('Merge'): continue stamp = datetime.utcfromtimestamp(entry.commit.commit_time) delta = timedelta(hours=3) last_update = (stamp - delta).strftime('%d/%m/%Y' + ' ás ' + '%H:%M:%S') data['local'] = local_ref data['remote'] = remote_commit data['last_update'] = last_update #print(data) # tag_labels = tag_list(repo) # print(tag_labels) # for i in ref.get_walker(include=[local_ref]): # print(i) # import git # repo = git.Repo(".") # tree = repo.tree() # for blob in tree: # commit = next(repo.iter_commits(paths=blob.path, max_count=1)) # print(blob.path, commit.author, commit.committed_date) # path = sys.argv[0].encode('utf-8') # w = ref.get_walker(paths=[path], c = next(iter(w)).commit) # try: # c = next(iter(w)).commit # except StopIteration: # print("No file %s anywhere in history." % sys.argv[0]) # else: # print("%s was last changed by %s at %s (commit %s)" % ( # sys.argv[1], c.author, time.ctime(c.author_time), c.id)) # log = porcelain.log('.', max_entries=1) # print(log) # log = porcelain.log(LOCAL_REPO) # print(log) # changes = porcelain.get_tree_changes(LOCAL_REPO) # print(changes) # status = porcelain.status(LOCAL_REPO) # print(status) # r = porcelain.fetch(LOCAL_REPO,REMOTE_REPO) # print(r) # for i in r: # print(i) if local_ref != remote_commit: pass # print('\nNOVA VERSÃO DISPONÍVEL,INSTALANDO...\n') # update() else: pass # print('\nVC JÁ ESTÁ COM A ÚLTIMA VERSÃO INSTALADA.') return data