summaryrefslogtreecommitdiff
path: root/src/buildstream/_gitsourcebase.py
Commit message (Collapse)AuthorAgeFilesLines
* Document my changes to the Git source plugin in NEWSTom Mewett2020-01-241-0/+1
| | | | | This includes adding an entry for the recursive submodules changes from !1765, and adding myself to the authors of _gitsourcebase.py.
* _gitsourcebase.py: Refactor latest_commit_with_tagsTom Mewett2020-01-241-19/+49
| | | | | The functionality has been split into three new functions: to_commit, reachable_tags, and describe. No behaviour is changed.
* _gitsourcebase.py: Strip git-describe tag info from cache keyTom Mewett2020-01-241-1/+10
| | | | | | | | | | | The beginning parts of git-describe labels are completely arbitrary. They can be changed either manually or by a track (e.g. if a tag is moved, added or deleted) even if the referenced commit is the same. Hence, only the commit ID part of the label should factor into the cache key. This commit, of course, breaks cache keys for artifacts built with the 'git' source with git-describe refs.
* _gitsourcebase.py: Fetch with depth=1 when an available tag is givenTom Mewett2020-01-241-16/+88
|
* _gitsourcebase.py: Refactor fetching and trackingTom Mewett2020-01-241-44/+15
| | | | | | | | | | This changes how the Git repo in the source cache is managed. The mirror is not created with an initial clone, but is set up manually from an empty repo. This is to support shallow cloning in future changes. To simplifiy code and Git calls, remotes are no longer used; instead URLs are passed on the command-line.
* source.py: Remove 'get_consistency' completelyBenjamin Schubert2020-01-161-8/+1
| | | | | This is not needed now that we have 'is_resolved' and 'is_cached'. We can therefore drop all calling places and implementations of it.
* source.py: Remove the reliance on consistency to get whether a source is cachedBenjamin Schubert2020-01-161-0/+3
| | | | | | | | | | | | | | | | | This removes the need to use consistency in Sources, by asking explicitely whether the source is cached or not. This introduces a new public method on source: `is_cached` that needs implementation and that should return whether the source has a local copy or not. - On fetch, also reset whether the source was cached or set if as cached when we know it was. - Validate the cache's source after fetching it This doesn't need to be run in the scheduler's process and can be offloaded to the child, which will allow better multiprocessing
* source.py: Add a new 'is_resolved' to get whether a source is resolved.Benjamin Schubert2020-01-161-0/+3
| | | | | | | | | | | | | | | `get_consistency` is coarse grained and hard to optimize, in addition to being un-userfriendly. This adds a new `is_resolved` that has for default implementation `get_ref() is not None`, which is true for most sources in BuildStream. Sources for which this is not true can override the method to give a more accurate description. Checking for this before looking whether the source is cached can reduce the amount of work necessary in some pipeline and opens the door for more optimizations and the removal of the source state check.
* _gitsourcebase.py: Rename and refactor _ignore_submoduleTom Mewett2019-12-131-11/+12
| | | | | "Ignore submodule" sounds like it could be an action, so this changes the name to more clearly be a predicate.
* _gitsourcebase.py: Manage submodules recursivelyTom Mewett2019-12-131-56/+65
| | | | | | | | | | | Previously, GitSourceBase would only consider immediate submodules of the superproject. It now fetches and stages recursively. To achieve this, this commit somewhat refactors the relationship between GitMirror and GitSourceBase. Enumerating GitMirrors for the submodules is now done in GitMirror itself. GitSourceBase recursively iterates these mirror classes with _recurse_submodules and applies the source configuration with _configure_submodules.
* _gitsourcebase.py: Add and update some comments on _GitMirrorTom Mewett2019-12-131-3/+14
|
* Reformat code using BlackChandan Singh2019-11-141-192/+233
| | | | | | | As discussed over the mailing list, reformat code using Black. This is a one-off change to reformat all our codebase. Moving forward, we shouldn't expect such blanket reformats. Rather, we expect each change to already comply with the Black formatting style.
* _gitsourcebase.py: Return 'None' when the ref is unsetbschubert/fix-git-refBenjamin Schubert2019-11-011-0/+2
| | | | | As per the documentation, sources are required to return 'None' when their ref is unset.
* node: Add 'as_enum' on ScalarNode and 'get_enum' helper on MappingNodeBenjamin Schubert2019-07-291-5/+8
| | | | | | | | This adds a method to ensure that a value is from a set of valid values and raises an error message accordingly. - Define Enum types for each of the relevant cases - Adapt call places that were doing such things manually
* plugin: remove 'node_get_provenance', use the Node API directlyBenjamin Schubert2019-07-151-1/+1
|
* _yaml: Remove 'node_validate' and replace by 'MappingNode.validate_keys'Benjamin Schubert2019-07-151-2/+2
| | | | - adapt all call sites to use the new API
* _yaml: Remove 'node_keys' and add 'MappingNode.keys' to replace itBenjamin Schubert2019-07-151-1/+1
| | | | | This mimics the dict.keys() method but returns a list instead of a dict_keys, for cython performance reasons
* _yaml: Introduce 'get_sequence()' and 'sequence_at()'/'mapping_at()'Benjamin Schubert2019-07-151-2/+2
| | | | | | | | | - Adding 'get_sequence' on MappingNode to access sequences in a mapping - Adding 'sequence_at' on SequenceNode to access sequences in a sequence - Adding 'mapping_at' on SequenceNode to access mappings in a sequence Using "*_at" in sequences allows us to quickly understand if we are dealing with a sequence or a mapping.
* _yaml: Add 'as_bool()' and 'is_none()' to ScalarNodeBenjamin Schubert2019-07-151-4/+4
| | | | | | | | | | | - 'as_bool()' casts a ScalarNode into a boolean, understanding both 'True' and 'False' as truthy-falsy values, as per node_get(type=bool) behavior - 'is_none()' allwos checking whether the scalar node contains a 'None' value. Since 'None' cannot be used when working with booleans, we need to have a way of checking for 'None' when we actually need the information of whether the value is unset. - Adapt all call places to use the new API
* _yaml: Add 'as_str()' on ScalarNode and 'get_scalar()' on MappingNodeBenjamin Schubert2019-07-151-8/+8
| | | | | | | | | | - 'get_scalar()' allows retrieving a scalar node from a mapping. - 'as_str()' casts a ScalarNode into a string (thus removing the node information). Both together, those replace 'node_get(mapping, key, type=str)' but also allow retrieving the 'Node' itself, which will allow in the future lazier provenance computation.
* _yaml: add 'get_mapping()' to MappingNodeBenjamin Schubert2019-07-151-2/+2
| | | | | | | | This allows to get a mapping node from another 'MappingNode', replacing 'node_get(my_mapping, key, type=dict)' Also changes all places where 'node_get' was called like that by the new API.
* _gitsourcebase: ignore or fix arguments-differ errAngelos Evripiotis2019-06-181-6/+6
| | | | | | | | | | | | PyLint helpfully points out that _GitMirror.fetch() does not match SourceFetcher.fetch() - it is missing the *kwargs argument. The same for _GitSourceBase.track(). Move towards being able to enable the 'arguments-differ' error faster by side-stepping the class design debate and ignoring the error for now. Change _GitSourceBase.set_ref() argument names to match Source.set_ref().
* _yaml.pyx: Forbid expected_type=Mapping, and remove isinstance checkBenjamin Schubert2019-06-031-3/+2
| | | | | | | | | | | Calls to `isinstance` can be particularily costly. Using type() is much faster. The only known case where the `isinstance` was useful is for dictionnaries where we would ask for a 'Mapping' instead. Disallowing 'Mapping' for expected_type considerably speeds up the calls to this functions. Also add into NEWS
* Move source from 'buildstream' to 'src/buildstream'Chandan Singh2019-05-211-0/+683
This was discussed in #1008. Fixes #1009.