* Callers who receive this reference must not modify its contents (as
* it can point to internal cached data).
*
* @return Raw contents of the file. Do not modify it.
*/
@NonNull
public byte[] getContents() {
return contents;
}
/**
* Get file mode
*
* @return Git file mode for this file (e.g. executable or regular)
*/
@NonNull
public FileMode getFileMode() {
return fileMode;
}
}
/** A default implementation of {@link RemoteReader} callback. */
public static class DefaultRemoteReader implements RemoteReader {
@Override
public ObjectId sha1(String uri, String ref) throws GitAPIException {
Map
* Calling {@link #setInputStream} will ignore the path set here.
*
* @param path
* (with
* Setting inputStream will ignore the path set. It will be closed in
* {@link #call}.
*
* @param inputStream a {@link java.io.InputStream} object.
* @return this command
* @since 3.5
*/
public RepoCommand setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
return this;
}
/**
* Set base URI of the paths inside the XML. This is typically the name of
* the directory holding the manifest repository, eg. for
* https://android.googlesource.com/platform/manifest, this should be
* /platform (if you would run this on android.googlesource.com) or
* https://android.googlesource.com/platform elsewhere.
*
* @param uri
* the base URI
* @return this command
*/
public RepoCommand setURI(String uri) {
this.baseUri = uri;
return this;
}
/**
* Set the URI of the superproject (this repository), so the .gitmodules
* file can specify the submodule URLs relative to the superproject.
*
* @param uri
* the URI of the repository holding the superproject.
* @return this command
* @since 4.8
*/
public RepoCommand setTargetURI(String uri) {
// The repo name is interpreted as a directory, for example
// Gerrit (http://gerrit.googlesource.com/gerrit) has a
// .gitmodules referencing ../plugins/hooks, which is
// on http://gerrit.googlesource.com/plugins/hooks,
this.targetUri = URI.create(uri + "/"); //$NON-NLS-1$
return this;
}
/**
* Set groups to sync
*
* @param groups groups separated by comma, examples: default|all|G1,-G2,-G3
* @return this command
*/
public RepoCommand setGroups(String groups) {
this.groupsParam = groups;
return this;
}
/**
* Set default branch.
*
* This is generally the name of the branch the manifest file was in. If
* there's no default revision (branch) specified in manifest and no
* revision specified in project, this branch will be used.
*
* @param branch
* a branch name
* @return this command
*/
public RepoCommand setBranch(String branch) {
this.branch = branch;
return this;
}
/**
* Set target branch.
*
* This is the target branch of the super project to be updated. If not set,
* default is HEAD.
*
* For non-bare repositories, HEAD will always be used and this will be
* ignored.
*
* @param branch
* branch name
* @return this command
* @since 4.1
*/
public RepoCommand setTargetBranch(String branch) {
this.targetBranch = Constants.R_HEADS + branch;
return this;
}
/**
* Set whether the branch name should be recorded in .gitmodules.
*
* Submodule entries in .gitmodules can include a "branch" field
* to indicate what remote branch each submodule tracks.
*
* That field is used by "git submodule update --remote" to update
* to the tip of the tracked branch when asked and by Gerrit to
* update the superproject when a change on that branch is merged.
*
* Subprojects that request a specific commit or tag will not have
* a branch name recorded.
*
* Not implemented for non-bare repositories.
*
* @param enable Whether to record the branch name
* @return this command
* @since 4.2
*/
public RepoCommand setRecordRemoteBranch(boolean enable) {
this.bareWriterConfig.recordRemoteBranch = enable;
return this;
}
/**
* Set whether the labels field should be recorded as a label in
* .gitattributes.
*
* Not implemented for non-bare repositories.
*
* @param enable Whether to record the labels in the .gitattributes
* @return this command
* @since 4.4
*/
public RepoCommand setRecordSubmoduleLabels(boolean enable) {
this.bareWriterConfig.recordSubmoduleLabels = enable;
return this;
}
/**
* Set whether the clone-depth field should be recorded as a shallow
* recommendation in .gitmodules.
*
* Not implemented for non-bare repositories.
*
* @param enable Whether to record the shallow recommendation.
* @return this command
* @since 4.4
*/
public RepoCommand setRecommendShallow(boolean enable) {
this.bareWriterConfig.recordShallowSubmodules = enable;
return this;
}
/**
* The progress monitor associated with the clone operation. By default,
* this is set to
* When set to true, we'll just skip the manifest entry and continue
* on to the next one.
*
* When set to false (default), we'll throw an error when remote
* failures occur.
*
* Not implemented for non-bare repositories.
*
* @param ignore Whether to ignore the remote failures.
* @return this command
* @since 4.3
*/
public RepoCommand setIgnoreRemoteFailures(boolean ignore) {
this.bareWriterConfig.ignoreRemoteFailures = ignore;
return this;
}
/**
* Set the author/committer for the bare repository commit.
*
* For non-bare repositories, the current user will be used and this will be
* ignored.
*
* @param author
* the author's {@link org.eclipse.jgit.lib.PersonIdent}
* @return this command
*/
public RepoCommand setAuthor(PersonIdent author) {
this.author = author;
return this;
}
/**
* Set the GetHeadFromUri callback.
*
* This is only used in bare repositories.
*
* @param callback
* a {@link org.eclipse.jgit.gitrepo.RepoCommand.RemoteReader}
* object.
* @return this command
*/
public RepoCommand setRemoteReader(RemoteReader callback) {
this.callback = callback;
return this;
}
/**
* Set the IncludedFileReader callback.
*
* @param reader
* a
* {@link org.eclipse.jgit.gitrepo.ManifestParser.IncludedFileReader}
* object.
* @return this command
* @since 4.0
*/
public RepoCommand setIncludedFileReader(IncludedFileReader reader) {
this.includedReader = reader;
return this;
}
/**
* Create a file with the given content in the destination repository
*
* @param path
* where to create the file in the destination repository
* @param contents
* content for the create file
* @return this command
*
* @since 6.1
*/
public RepoCommand addToDestination(String path, String contents) {
this.extraContents.add(new ExtraContent(path, contents));
return this;
}
@Override
public RevCommit call() throws GitAPIException {
checkCallable();
if (baseUri == null) {
baseUri = ""; //$NON-NLS-1$
}
if (inputStream == null) {
if (manifestPath == null || manifestPath.length() == 0)
throw new IllegalArgumentException(
JGitText.get().pathNotConfigured);
try {
inputStream = new FileInputStream(manifestPath);
} catch (IOException e) {
throw new IllegalArgumentException(
JGitText.get().pathNotConfigured, e);
}
}
List/
as separator)
* @return this command
*/
public RepoCommand setPath(String path) {
this.manifestPath = path;
return this;
}
/**
* Set the input stream to the manifest XML.
* NullProgressMonitor
*
* @see org.eclipse.jgit.lib.NullProgressMonitor
* @param monitor
* a {@link org.eclipse.jgit.lib.ProgressMonitor}
* @return this command
*/
public RepoCommand setProgressMonitor(ProgressMonitor monitor) {
this.monitor = monitor;
return this;
}
/**
* Set whether to skip projects whose commits don't exist remotely.
*