diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-11-26 11:24:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-26 11:24:45 -0500 |
commit | d6f848bd3dccaf7f274039066e8aa6058c04b01e (patch) | |
tree | 9bcf71b4542f4560d52d72aa31a579edebf0fe5d /mesonbuild | |
parent | 7e1b674704a2afa469797e18fc777ecdd8564b0f (diff) | |
parent | 0ebf033f3175c8de13e7950a51efe8fe16b4b247 (diff) | |
download | meson-d6f848bd3dccaf7f274039066e8aa6058c04b01e.zip meson-d6f848bd3dccaf7f274039066e8aa6058c04b01e.tar.gz meson-d6f848bd3dccaf7f274039066e8aa6058c04b01e.tar.bz2 |
Merge pull request #1059 from thiblahute/master
Allow specifying push URL in .wrap and fix broken subproject directories handling
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/wrap/wrap.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index e05c641..19ed39a 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -93,9 +93,19 @@ class Resolver: def resolve(self, packagename): fname = os.path.join(self.subdir_root, packagename + '.wrap') dirname = os.path.join(self.subdir_root, packagename) - if os.path.isdir(dirname): - # The directory is there? Great, use it. - return packagename + try: + if os.listdir(dirname): + # The directory is there and not empty? Great, use it. + return packagename + else: + mlog.warning('Subproject directory %s is empty, possibly because of an unfinished' + 'checkout, removing to reclone' % dirname) + os.rmdir(checkoutdir) + except NotADirectoryError: + raise RuntimeError('%s is not a directory, can not use as subproject.' % dirname) + except FileNotFoundError: + pass + if not os.path.isfile(fname): # No wrap file with this name? Give up. return None @@ -118,6 +128,15 @@ class Resolver: revno = p.get('revision') is_there = os.path.isdir(checkoutdir) if is_there: + try: + subprocess.check_call(['git', 'rev-parse']) + is_there = True + except subprocess.CalledProcessError: + raise RuntimeError('%s is not empty but is not a valid ' + 'git repository, we can not work with it' + ' as a subproject directory.' % ( + checkoutdir)) + if revno.lower() == 'head': # Failure to do pull is not a fatal error, # because otherwise you can't develop without @@ -134,6 +153,11 @@ class Resolver: if revno.lower() != 'head': subprocess.check_call(['git', 'checkout', revno], cwd=checkoutdir) + push_url = p.get('push-url') + if push_url: + subprocess.check_call(['git', 'remote', 'set-url', + '--push', 'origin', push_url], + cwd=checkoutdir) def get_hg(self, p): checkoutdir = os.path.join(self.subdir_root, p.get('directory')) revno = p.get('revision') |