@Override public CreateCommitCommand build() { return new CreateCommitCommand( super.resource(), checkNotNull(this.repositoryLocation,"Repository location cannot be null"), checkNotNull(this.branchName,"Branch name cannot be null"), checkNotNull(this.commitId,"Commit identifier cannot be null")); }
private Branch findBranch(final CreateCommitCommand aCommand) { final BranchId branchId=BranchId.create(aCommand.repositoryLocation(), aCommand.branchName()); final Branch branch = branchRepository().branchOfId(branchId); checkArgument(branch!=null,"No branch for repository located at '%s' with name '%s' is registered",branchId.repository(),branchId.name()); return branch; }
public void createCommit(final CreateCommitCommand aCommand) { checkNotNull(aCommand,COMMAND_CANNOT_BE_NULL); final Branch branch=findBranch(aCommand); final Commit commit = branch.createCommit(aCommand.commitId(), aCommand.commitResource()); commitRepository().add(commit); }
private void createCommit( final EnrichmentContext context, final ExecutionEnrichment enrichment, final URI repositoryLocation, final String branchName, final String commitId) { final URI commitResource = enrichment.commitResource().get(); this.scmService.createCommit( CreateCommitCommand. builder(). withRepositoryLocation(repositoryLocation). withBranchName(branchName). withCommitId(commitId). withResource(commitResource). build()); context.setCommitResource(commitResource); LOGGER.debug("Created commit {} ({}) in branch {} of repository {}",commitId,commitResource,branchName,repositoryLocation); }
private static Execution createExecution(final ExecutionRepository repository, final SourceCodeManagementService scmService, final Build build, final Execution execution, final int executionIdi, final Status status) { Date date=build.createdOn(); if(execution!=null) { if(execution.isFinished()) { date=execution.result().finishedOn(); } else { date=execution.createdOn(); } } final Execution newExecution=build.addExecution(executionId(build, executionIdi), after(date), build.codebase(), randomSHA1(build,executionIdi)); if(status!=null) { newExecution.finish(new Result(status,after(newExecution.createdOn()))); } repository.add(newExecution); final CreateCommitCommand command = CreateCommitCommand. builder(). withRepositoryLocation(newExecution.codebase().location()). withBranchName(newExecution.codebase().branchName()). withCommitId(newExecution.commitId()). withResource(build.buildId().resolve("scm/repo/master/"+newExecution.commitId()+"/")). build(); scmService.createCommit(command); return newExecution; }