Mix.SCMbehaviour(Mix v1.18.3)
View SourceThis module provides helper functions and defines thebehaviour required by any source code manager (SCM) used by Mix.
Summary
Callbacks
This behaviour function receives a keyword list ofopts
and should return an updated list in case the SCM consumesthe available options. For example, when a developer specifiesa dependency
This behaviour function returns a boolean if thedependency is available.
This behaviour function checks out dependencies.
Receives two options and must returntrue
if they refer to thesame repository. The options are guaranteed to belong to thesame SCM.
Returns a boolean if the dependency can be fetchedor it is meant to be previously available in thefile system.
Returns a string representing the SCM. This is usedwhen printing the dependency and not for inspection,so the amount of information should be concise andeasy to spot.
Returns a string representing the SCM. This is usedwhen printing the dependency and not for inspection,so the amount of information should be concise andeasy to spot.
This behaviour function checks the status of the lock. Inparticular, it checks if the revision stored in the lockis the same as the repository it is currently in.
Returns the usable managers for the dependency. This can be usedif the SCM has extra knowledge of the dependency, otherwise itshould return an empty list.
This behaviour function updates dependencies. It may becalled bydeps.get
ordeps.update
.
Functions
Appends the given SCM module to the list of available SCMs.
Returns all available SCMs. Each SCM is tried in orderuntil a matching one is found.
Deletes the given SCM from the list of available SCMs.
Prepends the given SCM module to the list of available SCMs.
Types
Callbacks
This behaviour function receives a keyword list ofopts
and should return an updated list in case the SCM consumesthe available options. For example, when a developer specifiesa dependency:
{:foo,"0.1.0",github:"foo/bar"}
Each registered SCM will be asked if they consume this dependency,receiving[github: "foo/bar"]
as argument. Since this option makessense for the Git SCM, it will return an update list of optionswhile other SCMs would simply returnnil
.
This behaviour function returns a boolean if thedependency is available.
This behaviour function checks out dependencies.
If the dependency is locked, a lock is received inopts
and the repository must be check out at the lock. Otherwise,no lock is given and the repository can be checked outto the latest version.
It must return the current lock.
Receives two options and must returntrue
if they refer to thesame repository. The options are guaranteed to belong to thesame SCM.
@callback fetchable?() ::boolean()
Returns a boolean if the dependency can be fetchedor it is meant to be previously available in thefile system.
Local dependencies (i.e. non-fetchable ones) are automaticallyrecompiled every time the parent project is compiled.
Returns a string representing the SCM. This is usedwhen printing the dependency and not for inspection,so the amount of information should be concise andeasy to spot.
Returns a string representing the SCM. This is usedwhen printing the dependency and not for inspection,so the amount of information should be concise andeasy to spot.
If nil is returned, it means no lock information is available.
@callback lock_status(opts()) :: :mismatch | :outdated | :ok
This behaviour function checks the status of the lock. Inparticular, it checks if the revision stored in the lockis the same as the repository it is currently in.
It may return:
:mismatch
- if the lock doesn't match and we need tosimply move to the latest lock:outdated
- the repository options are outdated in thelock and we need to trigger a full update:ok
- everything is fine
The lock is sent viaopts[:lock]
but it may not always beavailable. In such cases, if the SCM requires a lock, it mustreturn:mismatch
, otherwise simply:ok
.
Note the lock may also belong to another SCM and as such, anstructural check is required. A structural mismatch should alwaysreturn:outdated
.
Returns the usable managers for the dependency. This can be usedif the SCM has extra knowledge of the dependency, otherwise itshould return an empty list.
This behaviour function updates dependencies. It may becalled bydeps.get
ordeps.update
.
In the first scenario, a lock is received inopts
andthe repository must be updated to the lock. In the second,no lock is given and the repository can be updated freely.
It must return the current lock.
Functions
Appends the given SCM module to the list of available SCMs.
Returns all available SCMs. Each SCM is tried in orderuntil a matching one is found.
Deletes the given SCM from the list of available SCMs.
Prepends the given SCM module to the list of available SCMs.