Interface RefSyncService
repositories
and their upstream. For example,
for a fork
, the upstream might be its origin
. The goal is
to allow developers working on downstream repositories, like forks, to keep up to date with upstream without manually
fetching from upstream and then pushing downstream.-
Method Summary
Modifier and TypeMethodDescriptiongetStatus
(com.atlassian.bitbucket.repository.Repository repository) Retrieves the completestatus
for synchronization of the specified repository, returningnull
if synchronization has not been configured.Retrieves thestatus
a single ref within the specified repository.boolean
isAvailable
(com.atlassian.bitbucket.repository.Repository repository) Retrieves a flag indicating whether ref synchronization can beenabled
for the specifiedrepository
.boolean
isEnabled
(com.atlassian.bitbucket.repository.Repository repository) Retrieves a flag indicating whether ref synchronization has been enabled for the specifiedrepository
.void
setEnabled
(com.atlassian.bitbucket.repository.Repository repository, boolean enabled) Enables or disables ref synchronization for the specifiedrepository
.void
synchronize
(RefSyncRequest request) Performs a specificaction
to synchronize a ref within a specified repository.
-
Method Details
-
getStatus
@Nullable RefSyncStatus getStatus(@Nonnull com.atlassian.bitbucket.repository.Repository repository) Retrieves the completestatus
for synchronization of the specified repository, returningnull
if synchronization has not been configured.- Parameters:
repository
- the repository to retrieve synchronization status for- Returns:
- the complete status, detailing all out-of-sync
refs
, ornull
if synchronization has not been configured for the specified repository
-
getStatus
@Nullable RejectedRef getStatus(@Nonnull com.atlassian.bitbucket.repository.Repository repository, @Nonnull String refId) Retrieves thestatus
a single ref within the specified repository. If the ref is in sync with the repository'sorigin
,null
will be returned.- Parameters:
repository
- the repository to check the ref inrefId
- the ref to check within the specified repository- Returns:
status
details for the specified ref within the repository, if it is not in sync, ornull
if synchronization has not been configured for the specified repository or the ref is in sync
-
isAvailable
boolean isAvailable(@Nonnull com.atlassian.bitbucket.repository.Repository repository) Retrieves a flag indicating whether ref synchronization can beenabled
for the specifiedrepository
.Synchronization is not available for:
- Repositories with no
origin
, as there is no upstream repository to synchronize with Personal
forks for which theowning user
has lost read access to theorigin
, as synchronizing refs would expose commits the owner does not have access to
Whether synchronization is available can change over time. For example, for personal forks, the owner's permissions for the origin repository can be revoked. Even if synchronization is already enabled, if it is no longer available it will not be performed.
- Parameters:
repository
- the repository to check- Returns:
true
if synchronization is available for the specified repository; otherwise,false
- Repositories with no
-
isEnabled
boolean isEnabled(@Nonnull com.atlassian.bitbucket.repository.Repository repository) Retrieves a flag indicating whether ref synchronization has been enabled for the specifiedrepository
.Note: Even if synchronization is enabled, if it is no longer
available
it will not be performed.- Parameters:
repository
- the repository to check- Returns:
true
if synchronization has been enabled for the specified repository; otherwise,false
-
setEnabled
void setEnabled(@Nonnull com.atlassian.bitbucket.repository.Repository repository, boolean enabled) Enables or disables ref synchronization for the specifiedrepository
.When synchronization is disabled, any information about which refs are or are not in sync is lost. When synchronization is first enabled, no immediate synchronization is performed. The next push to the
upstream
repository will trigger synchronization and will add or update refs as appropriate.Note: If synchronization is disabled and refs are removed from the upstream repository, when synchronization is re-enabled those refs will never be removed unless a new ref appears in the upstream repository and is later deleted. To ensure the most consistent state for refs, synchronization should be left enabled.
- Parameters:
repository
- the repository to enable or disable synchronization forenabled
-true
to enable synchronization; otherwise,false
to disable it- Throws:
RefSyncNotAvailableException
- if synchronization is notavailable
for the specified repository
-
synchronize
Performs a specificaction
to synchronize a ref within a specified repository. Some actions may support additional parameters to control their behaviour. Such parameters are specified in thecontext
on the request.- Parameters:
request
- a context describing a repository and ref to synchronize, and the action to perform- Throws:
com.atlassian.bitbucket.AuthorisationException
- if called anonymously, or if the calling user does not have write access to the repository they are trying to synchronize inRefAlreadySynchronizedException
- if the specified ref is already in sync with its upstream, or if amerge
was requested for a ref which has notdiverged
from its upstreamRefSyncNotAvailableException
- if synchronization is notavailable
for the specified repository, even if it is enabled (meaning at some point previous it was available)RefSyncNotEnabledException
- if synchronization is notenabled
for the specified repository
-