[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,9 @@ 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
    +            if self.mirror.ref is None: #is there a better way to check if a ref is given.
    
    356
    +                detail = 'Without a tracking branch ref can not be updated but with out a ref then build can not fetch the repo and bst build will fail'
    
    357
    +                self.warn("{}: No tracking branch or reference has been defined".format(self), detail=detail)
    
    355 358
                 return None
    
    356 359
     
    
    357 360
             with self.timed_activity("Tracking {} from {}"
    

  • tests/sources/git.py
    ... ... @@ -359,3 +359,35 @@ 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
    +    print('element', element)
    
    384
    +    _yaml.dump(element, os.path.join(project, 'target.bst'))
    
    385
    +
    
    386
    +    # Track will encounter an inconsistent submodule without any ref
    
    387
    +    result = cli.run(project=project, args=['track', 'target.bst'])
    
    388
    +    result.assert_success()
    
    389
    +
    
    390
    +    # Assert that we are just fine without it, and emit a warning to the user.
    
    391
    +    assert "WARNING git source at" in result.stderr
    
    392
    +    assert "Without a tracking branch ref can not be updated but with out a ref " + \
    
    393
    +        "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]