export const shouldAutoSync = (
  settings: {
    autoSyncEnabled: boolean;
    requireCleanCompareForSync: boolean;
  },
  ctx: { status: string; forkAheadBy: number },
): boolean => {
  if (!settings.autoSyncEnabled) return false;
  if (ctx.status !== 'behind') return false;
  if (settings.requireCleanCompareForSync && ctx.forkAheadBy !== 0) {
    return false;
  }
  return ctx.forkAheadBy === 0;
};

export const shouldCreateReviewThread = (
  settings: { autoReviewEnabled: boolean },
  ctx: { status: string },
): boolean => settings.autoReviewEnabled && ctx.status === 'diverged';
