def source(dirname, filename, gen_content, url): if url is not None: print('{0} {1}'.format(dirname, url)) elif gen_content is not None: blob = git.blob(tree, filename) git.cat_file(blob, filename) print('{0} {1}'.format(dirname, filename)) b_chosen = choose() if b_chosen is None: return b_chosen.add_source(dirname, filename)
def get_ticket(self, sha): match = self.match_or_error(sha) contents = git.cat_file(it.ITDB_BRANCH + ':' + match) parent, fullsha = os.path.split(match) rel = os.path.basename(parent) sha7 = misc.chop(fullsha, 7) i = ticket.create_from_lines(contents, fullsha, rel) return (i, rel, fullsha, match)
def get_ticket(self, sha): match = self.match_or_error(sha) contents = git.cat_file(it.ITDB_BRANCH + ':' + match) parent, fullsha = os.path.split(match) rel = os.path.basename(parent) sha7 = misc.chop(fullsha, 7) i = ticket.create_from_lines(contents, fullsha, rel, True) return (i, rel, fullsha, match)
def blueprintignore(self): """ Return an open file pointer to the blueprint's blueprintignore file, which is suitable for passing back to `blueprint.rules.Rules.parse`. Prior to v3.0.9 this file was stored as .blueprintignore in the repository. Prior to v3.0.4 this file was stored as .gitignore in the repository. """ tree = git.tree(self._commit) blob = git.blob(tree, 'blueprintignore') if blob is None: blob = git.blob(tree, '.blueprintignore') if blob is None: blob = git.blob(tree, '.gitignore') if blob is None: return [] return git.cat_file(blob)
def list(self, show_types=['open', 'test'], releases_filter=[]): self.require_itdb() releasedirs = filter(lambda x: x[1] == 'tree', git.tree(it.ITDB_BRANCH + \ ':' + it.TICKET_DIR)) # Filter releases if releases_filter: filtered = [] for dir in releasedirs: _, _, _, name = dir if name in releases_filter: filtered.append(dir) releasedirs = filtered # Show message if no tickets there if len(releasedirs) == 0: print 'no tickets yet. use \'it new\' to add new tickets.' return # Collect tickets assigned to self on the way inbox = [] print_count = 0 releasedirs.sort(cmp_by_release_dir) for _, _, sha, rel in releasedirs: reldir = os.path.join(it.TICKET_DIR, rel) ticketfiles = git.tree(it.ITDB_BRANCH + ':' + reldir) tickets = [ ticket.create_from_lines(git.cat_file(sha), ticket_id, rel, True) \ for _, type, sha, ticket_id in ticketfiles \ if type == 'blob' and ticket_id != it.HOLD_FILE \ ] # Store the tickets in the inbox if neccessary inbox += filter(lambda t: t.is_mine(), tickets) print_count += self.__print_ticket_rows(rel, tickets, show_types, True, True) print_count += self.__print_ticket_rows( 'INBOX', inbox, (show_types == ['open', 'test']) and ['open'] or show_types, False, False) if print_count == 0: print 'use the -a flag to show all tickets'
def list(self, show_types = ['open', 'test'], releases_filter = []): self.require_itdb() releasedirs = filter(lambda x: x[1] == 'tree', git.tree(it.ITDB_BRANCH + \ ':' + it.TICKET_DIR)) # Filter releases if releases_filter: filtered = [] for dir in releasedirs: _, _, _, name = dir if name in releases_filter: filtered.append(dir) releasedirs = filtered # Show message if no tickets there if len(releasedirs) == 0: print 'no tickets yet. use \'it new\' to add new tickets.' return # Collect tickets assigned to self on the way inbox = [] print_count = 0 releasedirs.sort(cmp_by_release_dir) for _, _, sha, rel in releasedirs: reldir = os.path.join(it.TICKET_DIR, rel) ticketfiles = git.tree(it.ITDB_BRANCH + ':' + reldir) tickets = [ ticket.create_from_lines(git.cat_file(sha), ticket_id, rel, True) \ for _, type, sha, ticket_id in ticketfiles \ if type == 'blob' and ticket_id != it.HOLD_FILE \ ] # Store the tickets in the inbox if neccessary inbox += filter(lambda t: t.is_mine(), tickets) print_count += self.__print_ticket_rows(rel, tickets, show_types, True, True) print_count += self.__print_ticket_rows('INBOX', inbox, (show_types == ['open','test']) and ['open'] or show_types, False, False) if print_count == 0: print 'use the -a flag to show all tickets'