Skip to content

'publish' generates public access urls for files. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion git-fat
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 ['']
Expand Down Expand Up @@ -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)