[Sugar-devel] [PATCH sugar-toolkit] Bundlebuilder: don't fail to package if git is not installed, OLPC #11341

Sascha Silbe sascha-ml-reply-to-2011-4 at silbe.org
Mon Oct 24 08:43:42 EDT 2011


Excerpts from Simon Schampijer's message of 2011-10-21 12:27:02 +0200:

> We need to make sure that we do not fail if git is not
> installed and use the same fallback code as if we are
> in a directory where no git information is present.

How about:

"""
When git is installed, it will return non-zero if it gets asked to list
the files in a non-repository. The subprocess.Popen instantiation is
successful in this case and the returncode attribute will contain the
error code from git. The current code handles this fine.

If git isn't installed, however, trying to instantiate subprocess.Popen
will fail with OSError. We need to catch this and fall back to our own
source file listing facility like we do for the non-repository case.
"""

[sugar.activity.bundlebuilder.XOPackager]
>      def _get_files_in_git(self):
> -        git_ls = subprocess.Popen(['git', 'ls-files'], stdout=subprocess.PIPE,
> -                                  cwd=self.config.source_dir)
> +        try:
> +            git_ls = subprocess.Popen(['git', 'ls-files'],
> +                                      stdout=subprocess.PIPE,
> +                                      cwd=self.config.source_dir)
> +        except OSError:
> +            # Git not installed. Fall back to filtered list
> +            return list_files(self.config.source_dir,
> +                              IGNORE_DIRS, IGNORE_FILES)

Since our own listing code can generate different results than git
ls-files does, we should log a warning (same applies to
SourcePackager.get_files()).

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20111024/7837bdf4/attachment.pgp>


More information about the Sugar-devel mailing list