From: Jeff Epler <jepler@unpythonic.net>
To: demerphq <demerphq@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Adding files to a git-archive when it is generated, and whats the best way to find out what branch a commit is on?
Date: Wed, 29 Jul 2009 11:12:02 -0500 [thread overview]
Message-ID: <20090729161202.GA2443@unpythonic.net> (raw)
In-Reply-To: <9b18b3110907290115v1f30eeat748631bb09f92517@mail.gmail.com>
When I wanted to add extra files to a tar produced by git-archive, I
used python's tarfile module. This assumes the tar will fit comfortably
in memory. The specifics probably don't apply in your case, but maybe
it will be useful anyhow.
You could also use tar's -r or gnu tar's -A modes to add to the
git-archive tar once it's been created:
git-archive ... > temp.tar
tar -rf temp.tar additional-file
(unfortunately, -r and -A don't operate on pipes)
def main(args):
if len(args) == 1:
version = args[0]
elif len(args) > 1:
raise SystemExit, "Usage: %s [version]" % sys.argv[0]
else:
status, gitversion = commands.getstatusoutput("git-describe --tags")
version = highest_version()
if status != 0 or version != gitversion:
raise SystemExit, """\
Highest version %r doesn't match description %r.
Specify version number explicitly if this is what you want""" % (
version, gitversion)
version = version.lstrip("v")
DIRNAME = "%(p)s-%(v)s" % {'p': PACKAGE_NAME, 'v': version}
TARNAME = DIRNAME + '.tar.gz'
verstream = StringIO.StringIO("%s\n" % version)
verinfo = tarfile.TarInfo(DIRNAME + "/VERSION")
verinfo.mode = 0660
verinfo.size = len(verstream.getvalue())
verinfo.mtime = time.time()
tardata = os.popen("git-archive --prefix=%(p)s/ v%(v)s"
% {'p': DIRNAME, 'v': version}).read()
tarstream = StringIO.StringIO(tardata)
tar = tarfile.TarFile(mode="a", fileobj=tarstream)
tar.addfile(verinfo, verstream)
tar.close()
out = gzip.open("../" + TARNAME, "wb")
out.write(tarstream.getvalue())
out.close()
prev parent reply other threads:[~2009-07-29 16:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 8:15 Adding files to a git-archive when it is generated, and whats the best way to find out what branch a commit is on? demerphq
2009-07-29 8:40 ` Avery Pennarun
2009-07-29 8:41 ` Santi Béjar
2009-07-29 9:21 ` demerphq
2009-07-29 9:33 ` Santi Béjar
2009-07-29 9:51 ` demerphq
2009-07-29 11:13 ` Santi Béjar
2009-07-30 20:33 ` René Scharfe
2009-07-31 10:04 ` demerphq
[not found] ` <m3hbwtrpip.fsf@localhost.localdomain>
2009-07-31 13:48 ` demerphq
2009-08-02 13:52 ` René Scharfe
2009-08-02 14:19 ` demerphq
2009-08-04 17:50 ` René Scharfe
2009-07-29 16:12 ` Jeff Epler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090729161202.GA2443@unpythonic.net \
--to=jepler@unpythonic.net \
--cc=demerphq@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).