createCommit method

Future<CreateCommitOutput> createCommit({
  1. required String branchName,
  2. required String repositoryName,
  3. String? authorName,
  4. String? commitMessage,
  5. List<DeleteFileEntry>? deleteFiles,
  6. String? email,
  7. bool? keepEmptyFolders,
  8. String? parentCommitId,
  9. List<PutFileEntry>? putFiles,
  10. List<SetFileModeEntry>? setFileModes,
})

Creates a commit for a repository on the tip of a specified branch.

May throw RepositoryNameRequiredException. May throw InvalidRepositoryNameException. May throw RepositoryDoesNotExistException. May throw ParentCommitIdRequiredException. May throw InvalidParentCommitIdException. May throw ParentCommitDoesNotExistException. May throw ParentCommitIdOutdatedException. May throw BranchNameRequiredException. May throw InvalidBranchNameException. May throw BranchDoesNotExistException. May throw BranchNameIsTagNameException. May throw FileEntryRequiredException. May throw MaximumFileEntriesExceededException. May throw PutFileEntryConflictException. May throw SourceFileOrContentRequiredException. May throw FileContentAndSourceFileSpecifiedException. May throw PathRequiredException. May throw InvalidPathException. May throw SamePathRequestException. May throw FileDoesNotExistException. May throw FileContentSizeLimitExceededException. May throw FolderContentSizeLimitExceededException. May throw InvalidDeletionParameterException. May throw RestrictedSourceFileException. May throw FileModeRequiredException. May throw InvalidFileModeException. May throw NameLengthExceededException. May throw InvalidEmailException. May throw CommitMessageLengthExceededException. May throw EncryptionIntegrityChecksFailedException. May throw EncryptionKeyAccessDeniedException. May throw EncryptionKeyDisabledException. May throw EncryptionKeyNotFoundException. May throw EncryptionKeyUnavailableException. May throw NoChangeException. May throw FileNameConflictsWithDirectoryNameException. May throw DirectoryNameConflictsWithFileNameException. May throw FilePathConflictsWithSubmodulePathException.

Parameter branchName : The name of the branch where you create the commit.

Parameter repositoryName : The name of the repository where you create the commit.

Parameter authorName : The name of the author who created the commit. This information is used as both the author and committer for the commit.

Parameter commitMessage : The commit message you want to include in the commit. Commit messages are limited to 256 KB. If no message is specified, a default message is used.

Parameter deleteFiles : The files to delete in this commit. These files still exist in earlier commits.

Parameter email : The email address of the person who created the commit.

Parameter keepEmptyFolders : If the commit contains deletions, whether to keep a folder or folder structure if the changes leave the folders empty. If true, a ..gitkeep file is created for empty folders. The default is false.

Parameter parentCommitId : The ID of the commit that is the parent of the commit you create. Not required if this is an empty repository.

Parameter putFiles : The files to add or update in this commit.

Parameter setFileModes : The file modes to update for files in this commit.

Implementation

Future<CreateCommitOutput> createCommit({
  required String branchName,
  required String repositoryName,
  String? authorName,
  String? commitMessage,
  List<DeleteFileEntry>? deleteFiles,
  String? email,
  bool? keepEmptyFolders,
  String? parentCommitId,
  List<PutFileEntry>? putFiles,
  List<SetFileModeEntry>? setFileModes,
}) async {
  ArgumentError.checkNotNull(branchName, 'branchName');
  _s.validateStringLength(
    'branchName',
    branchName,
    1,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    1,
    100,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.CreateCommit'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'branchName': branchName,
      'repositoryName': repositoryName,
      if (authorName != null) 'authorName': authorName,
      if (commitMessage != null) 'commitMessage': commitMessage,
      if (deleteFiles != null) 'deleteFiles': deleteFiles,
      if (email != null) 'email': email,
      if (keepEmptyFolders != null) 'keepEmptyFolders': keepEmptyFolders,
      if (parentCommitId != null) 'parentCommitId': parentCommitId,
      if (putFiles != null) 'putFiles': putFiles,
      if (setFileModes != null) 'setFileModes': setFileModes,
    },
  );

  return CreateCommitOutput.fromJson(jsonResponse.body);
}