[Sugar-devel] [PATCH sugar-toolkit] Bundlebuilder: don't fail to package if git is not installed, OLPC #11341
simon at schampijer.de
Thu Nov 10 03:18:30 EST 2011
On 10/24/2011 02:43 PM, Sascha Silbe wrote:
> 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.
Sounds good to me.
>> 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
Yes, I can add the warning.
More information about the Sugar-devel