def find_files(self, head_commit): tree_sha = api.get_commit_tree_sha(self.full_name, head_commit) tree_sha = api.traverse_tree( self.full_name, os.path.join(self.locale_path, 'en-US').split('/'), tree_sha ) files = api.get_tree_blobs(self.full_name, tree_sha) files.append('install.rdf') return files
def save_to_github(self): parent_commit = self.repo.head_commit files = dict() for f in self.repo.file_set.all(): # TODO stop assuming install.rdf is at the top level if f.path == 'install.rdf': name = f.string_set.get(locale=self.locale, key='name').value description = f.string_set.get(locale=self.locale, key='description').value rdf = raw.get_raw_file(self.repo.full_name, parent_commit, 'install.rdf') parser = InstallRDFParser(rdf) parser.add_locale(self.locale.code, name, description) files['install.rdf'] = parser.reconstruct() continue path = f.get_full_path(self.locale) content = f.reconstruct(self.locale) files[path] = content message = 'Update %s translation' % self.locale.name if self.locale.code not in self.repo.translations_list_set: message = 'Add %s translation' % self.locale.name translations_list_set = self.repo.translations_list_set translations_list_set.append(self.locale.code) self.repo.translations_list_set = translations_list_set self.repo.save(update_fields=['translations_list']) # TODO stop assuming chrome.manifest is at the top level manifest = raw.get_raw_file(self.repo.full_name, parent_commit, 'chrome.manifest') parser = ChromeManifestParser(manifest) parser.add_locale(self.locale.code) files['chrome.manifest'] = parser.reconstruct() tree_sha = api.get_commit_tree_sha(self.repo.fork_name, parent_commit) tree_sha = api.save_files(self.repo.fork_name, tree_sha, files) author = { 'name': self.owner.username, 'email': self.owner.email } head_commit = api.create_commit( self.repo.fork_name, message, tree_sha, parent_commit, author=author ) api.update_head_commit_sha(self.repo.fork_name, self.branch_name, head_commit, force=True) self.dirty = False self.save(update_fields=['dirty']) self.set_strings_clean()