package com.huangzj.protoplugin.vcs;

import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.changes.CommitContext;
import com.intellij.openapi.vcs.checkin.CheckinHandler;
import com.intellij.openapi.vcs.checkin.CheckinHandlerFactory;
import org.jetbrains.annotations.NotNull;

/**
 * 注册 {@link TimeSkewCommitCheckHandler}：以 {@link com.intellij.openapi.vcs.checkin.CommitCheck.ExecutionOrder#EARLY}
 * 执行时间校验，避免非模态提交在 LATE 阶段失败触发 Cancelled/文档恢复（表现为文件被回退）。
 */
public final class CommitTimeCheckinHandlerFactory extends CheckinHandlerFactory {

    @Override
    public @NotNull CheckinHandler createHandler(
            @NotNull CheckinProjectPanel panel, @NotNull CommitContext commitContext) {
        return new TimeSkewCommitCheckHandler(panel.getProject());
    }
}
