Movatterモバイル変換


[0]ホーム

URL:


Mix.SCMbehaviour(Mix v1.18.3)

View Source

This module provides helper functions and defines thebehaviour required by any source code manager (SCM) used by Mix.

Summary

Types

A module implementing theMix.SCM behaviour.

Callbacks

This behaviour function receives a keyword list ofoptsand 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

opts()

@type opts() ::keyword()

t()

@type t() ::module()

A module implementing theMix.SCM behaviour.

Callbacks

accepts_options(app, opts)

@callback accepts_options(app ::atom(),opts()) ::opts() | nil

This behaviour function receives a keyword list ofoptsand 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.

checked_out?(opts)

@callback checked_out?(opts()) ::boolean()

This behaviour function returns a boolean if thedependency is available.

checkout(opts)

@callback checkout(opts()) ::any()

This behaviour function checks out dependencies.

If the dependency is locked, a lock is received inoptsand 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.

equal?(opts1, opts2)

@callback equal?(opts1 ::opts(), opts2 ::opts()) ::boolean()

Receives two options and must returntrue if they refer to thesame repository. The options are guaranteed to belong to thesame SCM.

fetchable?()

@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.

format(opts)

@callback format(opts()) ::String.t()

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.

format_lock(opts)

@callback format_lock(opts()) ::String.t() | nil

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.

lock_status(opts)

@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.

managers(opts)

@callback managers(opts()) :: [atom()]

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.

update(opts)

@callback update(opts()) ::any()

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

append(mod)

Appends the given SCM module to the list of available SCMs.

available()

Returns all available SCMs. Each SCM is tried in orderuntil a matching one is found.

delete(mod)

(since 1.16.2)

Deletes the given SCM from the list of available SCMs.

prepend(mod)

Prepends the given SCM module to the list of available SCMs.


[8]ページ先頭

©2009-2025 Movatter.jp