mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-06-01 13:21:41 +02:00
Update commit on branch refresh and validate commit exists on save
Refresh button now always updates the commit to the latest SHA instead of preserving the stale one in edit mode. Both create and update routes verify the commit still exists on GitHub before persisting.
This commit is contained in:
@@ -102,6 +102,9 @@
|
|||||||
<div class="invalid-feedback" ng-show="anonymize.commit.$error.pattern || anonymize.commit.$error.required">
|
<div class="invalid-feedback" ng-show="anonymize.commit.$error.pattern || anonymize.commit.$error.required">
|
||||||
The commit SHA is not valid.
|
The commit SHA is not valid.
|
||||||
</div>
|
</div>
|
||||||
|
<div class="invalid-feedback" ng-show="anonymize.commit.$error.exists">
|
||||||
|
This commit no longer exists in the repository. Click refresh to get the latest.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1600,11 +1600,11 @@ angular
|
|||||||
}
|
}
|
||||||
const selected = $scope.branches.filter((b) => b.name == $scope.source.branch);
|
const selected = $scope.branches.filter((b) => b.name == $scope.source.branch);
|
||||||
if (selected.length > 0) {
|
if (selected.length > 0) {
|
||||||
// Preserve the saved commit when editing with auto-update off:
|
// When the user explicitly clicks refresh (force=true), always
|
||||||
// refreshing branches must not silently bump the pinned SHA to
|
// update the commit to the latest on the branch. Only preserve
|
||||||
// GitHub HEAD. Same intent as the source.branch watcher (#360),
|
// the saved commit on the initial edit-page load (#360).
|
||||||
// extended to cover the branches refresh path.
|
|
||||||
const keepSavedCommit =
|
const keepSavedCommit =
|
||||||
|
!force &&
|
||||||
$scope.isUpdate &&
|
$scope.isUpdate &&
|
||||||
!$scope.options.update &&
|
!$scope.options.update &&
|
||||||
$scope._originalBranch === $scope.source.branch &&
|
$scope._originalBranch === $scope.source.branch &&
|
||||||
@@ -1957,6 +1957,7 @@ angular
|
|||||||
setValidity("sourceUrl", "missing", true);
|
setValidity("sourceUrl", "missing", true);
|
||||||
setValidity("sourceUrl", "access", true);
|
setValidity("sourceUrl", "access", true);
|
||||||
setValidity("sourceUrl", "github", true);
|
setValidity("sourceUrl", "github", true);
|
||||||
|
setValidity("commit", "exists", true);
|
||||||
setValidity("conference", "activated", true);
|
setValidity("conference", "activated", true);
|
||||||
setValidity("terms", "format", true);
|
setValidity("terms", "format", true);
|
||||||
$scope.termsRegexWarning = false;
|
$scope.termsRegexWarning = false;
|
||||||
@@ -1977,6 +1978,7 @@ angular
|
|||||||
case "invalid_terms_format": setValidity("terms", "format", false); break;
|
case "invalid_terms_format": setValidity("terms", "format", false); break;
|
||||||
case "repo_not_found": setValidity("sourceUrl", "missing", false); break;
|
case "repo_not_found": setValidity("sourceUrl", "missing", false); break;
|
||||||
case "repo_not_accessible": setValidity("sourceUrl", "access", false); break;
|
case "repo_not_accessible": setValidity("sourceUrl", "access", false); break;
|
||||||
|
case "commit_not_found": setValidity("commit", "exists", false); break;
|
||||||
case "conf_not_activated": setValidity("conference", "activated", false); break;
|
case "conf_not_activated": setValidity("conference", "activated", false); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,6 +431,11 @@ router.post(
|
|||||||
httpStatus: 404,
|
httpStatus: 404,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await repository.getCommitInfo(repoUpdate.source.commit, {
|
||||||
|
accessToken: user.accessToken,
|
||||||
|
});
|
||||||
|
|
||||||
const removeRepoFromConference = async (conferenceID: string) => {
|
const removeRepoFromConference = async (conferenceID: string) => {
|
||||||
const conf = await ConferenceModel.findOne({
|
const conf = await ConferenceModel.findOne({
|
||||||
conferenceID,
|
conferenceID,
|
||||||
@@ -542,6 +547,10 @@ router.post("/", async (req: express.Request, res: express.Response) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await repository.getCommitInfo(repoUpdate.source.commit, {
|
||||||
|
accessToken: user.accessToken,
|
||||||
|
});
|
||||||
|
|
||||||
const repo = new AnonymizedRepositoryModel();
|
const repo = new AnonymizedRepositoryModel();
|
||||||
repo.repoId = repoUpdate.repoId;
|
repo.repoId = repoUpdate.repoId;
|
||||||
repo.anonymizeDate = new Date();
|
repo.anonymizeDate = new Date();
|
||||||
|
|||||||
Reference in New Issue
Block a user