class CommitController extends AbstractRepositoryController {

	@PostMapping("/repos/{owner}/{repoName}/commits")
	public ResponseEntity<Map<String, Object>> commit(
			Principal principal,
			@PathVariable("owner") String owner,
			@PathVariable("repoName") String repoName,
			@Valid @RequestBody CommitMessage param,
			BindingResult bindingResult) {
		if(principal == null) {
			throw new NoAuthorizationException();
		}
		
		if(bindingResult.hasErrors()) {
			throw new InvalidRequestException(bindingResult);
		}
		
		Repository repository = repositoryService.find(owner, repoName).orElseThrow(ResourceNotFoundException::new);
		repositoryPermissionService.canWrite(principal, repository).orElseThrow(NoAuthorizationException::new);
		
		UserInfo user = userService.findByLoginName(principal.getName()).orElseThrow(NoAuthorizationException::new);
		try {
			repositoryResourceService.commit(user, repository, param.getValue());
		} catch(GitEmptyCommitException e) {
			bindingResult.reject("NotEmpty.gitCommit");
		}
		
		if(bindingResult.hasErrors()) {
			throw new InvalidRequestException(bindingResult);
		}
		
		return ResponseEntity.ok(Collections.emptyMap());
	}

}