[Notes] [Git][BuildStream/buildstream][willsalmon/trackWarning] git.py: Add warning to git track if track and ref are not present



Title: GitLab

Will Salmon pushed to branch willsalmon/trackWarning at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/plugins/sources/git.py
    ... ... @@ -352,6 +352,11 @@ class GitSource(Source):
    352 352
     
    
    353 353
             # If self.tracking is not specified it's not an error, just silently return
    
    354 354
             if not self.tracking:
    
    355
    +            # Is there a better way to check if a ref is given.
    
    356
    +            if self.mirror.ref is None:
    
    357
    +                detail = 'Without a tracking branch ref can not be updated but with out' + \
    
    358
    +                         'a ref then build can not fetch the repo and bst build will fail'
    
    359
    +                self.warn("{}: No tracking branch or reference has been defined".format(self), detail=detail)
    
    355 360
                 return None
    
    356 361
     
    
    357 362
             with self.timed_activity("Tracking {} from {}"
    

  • tests/sources/git.py
    ... ... @@ -359,3 +359,34 @@ def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles):
    359 359
     
    
    360 360
         # Assert that we are just fine without it, and emit a warning to the user.
    
    361 361
         assert "Ignoring inconsistent submodule" in result.stderr
    
    362
    +
    
    363
    +
    
    364
    +@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
    
    365
    +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'template'))
    
    366
    +def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles):
    
    367
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    368
    +
    
    369
    +    # Create the repo from 'repofiles' subdir
    
    370
    +    repo = create_repo('git', str(tmpdir))
    
    371
    +    ref = repo.create(os.path.join(project, 'repofiles'))
    
    372
    +
    
    373
    +    # Write out our test target
    
    374
    +    gitsource = repo.source_config(ref=None)
    
    375
    +    gitsource.pop('track')
    
    376
    +    element = {
    
    377
    +        'kind': 'import',
    
    378
    +        'sources': [
    
    379
    +            gitsource
    
    380
    +        ]
    
    381
    +    }
    
    382
    +
    
    383
    +    _yaml.dump(element, os.path.join(project, 'target.bst'))
    
    384
    +
    
    385
    +    # Track will encounter an inconsistent submodule without any ref
    
    386
    +    result = cli.run(project=project, args=['track', 'target.bst'])
    
    387
    +    result.assert_success()
    
    388
    +
    
    389
    +    # Assert that we are just fine without it, and emit a warning to the user.
    
    390
    +    assert "WARNING git source at" in result.stderr
    
    391
    +    assert "Without a tracking branch ref can not be updated but with out a ref " + \
    
    392
    +        "then build can not fetch the repo and bst build will fail" in result.stderr



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]