Re: how to git-archive ignore some files?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Victor,

On Tue, May 06, 2008 at 03:15:31PM -0300 or thereabouts, Victor Bogado da Silva Lins wrote:
> I want to use git-archive to create source packages, but my git
> repository has a .gitignore that I don't want to be pushed into the
> archive. So is it possible to keep the .gitignore file in the repository
> and create an archive(*) without it? 
> 
> *) using git-archive, off course. 

Others already discussed the --delete method with tar, and I do something
similar except slightly more flexible.  I have for example, a git repo
that checks out directories from CVS, and of course I don't want these
CVS directories in my 'release'.  So put a executable '.release' file in
each repo that tells my release script how to fix up the tarball to be
production ready.

Here is my release script, modeled after some lines Linus put in the git
documentation.  It is meant to be run, reviewed for mistakes, and then
have the commands run via cut-paste.

#!/bin/bash 
stable="$1"
last="$2"
new="$3"
chip="$4"
rel=`pwd | cut -d'/' -f6 | sed -e 's/\.git//'`

if [ -z $chip ]; then
	reldir=$rel
else
	reldir=$rel-$chip
fi

reldir="$reldir-$new"
tarfile="$reldir.tar"

if [ -d $reldir ]; then
	echo "release directory $reldir already exists, please remove" 1>&2
	exit 1
fi

if [ -f "../$reldir.tar" ]; then
	echo "Release file ../$reldir.tar already exists, please remove" 1>&2
	exit 1
fi

if [ -f "../$reldir.tar.gz" ]; then
	echo "Release file ../$reldir.tar.gz already exists, please remove" 1>&2
	exit 1
fi

echo "#git tag v$new"
echo "Tagging new release v$new" 1>&2
echo "git archive --prefix=$reldir/ v$new > ../$tarfile"
echo "mkdir $reldir"
#echo "git diff v$stable v$new | gzip -9 > ../patch-$new.gz"
echo "git log --no-merges v$new ^v$last > $reldir/ChangeLog-$new"
echo "git shortlog --no-merges v$new ^v$last > $reldir/ShortLog"
echo "git diff --stat --summary -M v$last v$new > $reldir/diffstat-$new"
echo "tar -rf ../$tarfile $reldir/*"
./.release $reldir ../$tarfile
if [ $? != 0 ]; then
	echo ".release script failed! removing generated files" 1>&2
	echo "rm -rf $reldir ../$tarfile"
	exit 1
fi
echo "gzip -9 < ../$tarfile > ../$tarfile.gz"
echo "rm -rf $reldir ../$tarfile"
echo "New release at ../$tarfile.gz" 1>&2

And an example .release file

#!/bin/bash
dirlist="make foo_include scripts"
excludes="--exclude CVS --exclude '*.o' --exclude '*.swp' --exclude '*.d' --exclude '*.a'"
reldir=$1
tarfile=$2
#echo "make doc && make -C doc/latex pdf"
echo "cp -a $dirlist $reldir"
echo "cp Makefile.release $reldir/Makefile"
echo "tar $excludes -rf $tarfile $reldir/*"

# write over the makefile
echo "cp Makefile.release $reldir/Makefile"
echo "tar -u -f $tarfile $reldir/Makefile"
echo "tar --delete --file=$tarfile $reldir/Makefile.release"

# delete the doxygen file
echo "cp Doxyfile $reldir"
echo "tar --delete --file=$tarfile $reldir/Doxyfile"

# remove traces of the release file
echo "tar --delete --file=$tarfile $reldir/.release"

Attachment: pgpewno7sPE2b.pgp
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux