diff --git a/git-fat b/git-fat index f34ab5a..90067a2 100755 --- a/git-fat +++ b/git-fat @@ -78,6 +78,17 @@ try: os.remove(localfile) raise + def locate_public_url(self,files): + bkt = self.get_bucket() + for file, realname in files: + localfile = os.path.abspath(os.path.join(self.objdir,file)) + self.verbose('Getting object %s from s3 bucket %s' % (file,self.bucket)) + k = Key(bkt) + k.key = file + k.make_public() + url = k.generate_url(0, query_auth=False) + print('%s => %s' % (realname, url)) + def push(self,files): bkt = self.get_bucket() for file in files: @@ -518,6 +529,27 @@ class GitFat(object): self.backend.pull(files) self.checkout() + def cmd_locate(self, args): + 'locate the blob objects for files given in the command line; publish the blob if -p is given' + self.setup() + files = [] + publish = '-p' in args + + for arg in args: + if arg.startswith('-'): + continue + if os.path.exists(arg): + mode, blobsha1, stageno, filename = \ + subprocess.check_output(['git', 'ls-files', '-s', arg]).split() + stub = subprocess.check_output(['git', 'cat-file', 'blob', blobsha1]).splitlines() + digest, bytecount = self.decode(stub[0]) + files.append((digest, arg)) + if not publish: + for file, realname in files: + print('%s => %s' % (realname, file)) + else: + self.backend.locate_public_url(files) + def parse_pull_patterns(self, args): if '--' not in args: return [''] @@ -677,5 +709,7 @@ if __name__ == '__main__': fat.cmd_find(sys.argv[2:]) elif cmd == 'index-filter': fat.cmd_index_filter(sys.argv[2:]) + elif cmd == 'locate': + fat.cmd_locate(sys.argv[2:]) else: - print('Usage: git fat [init|status|push|pull|gc|checkout|find|index-filter]', file=sys.stderr) + print('Usage: git fat [init|status|push|pull|gc|checkout|find|index-filter|publish]', file=sys.stderr)