backport
Version:
A CLI tool that automates the process of backporting commits
50 lines • 1.58 kB
JavaScript
import { graphql } from '../graphql/generated/index.js';
import { parseConfigFile } from '../options/config/read-config-file.js';
import { logger } from './logger.js';
export const RemoteConfigHistoryFragment = graphql(`
fragment RemoteConfigHistoryFragment on Commit {
remoteConfigHistory: history(first: 1, path: ".backportrc.json") {
edges {
remoteConfig: node {
committedDate
file(path: ".backportrc.json") {
... on TreeEntry {
__typename
object {
... on Blob {
__typename
text
}
}
}
}
}
}
}
}
`);
export function parseRemoteConfigFile(remoteConfig) {
try {
const text = remoteConfig?.file?.object?.__typename === 'Blob'
? remoteConfig.file.object.text
: undefined;
if (!text)
return;
return parseConfigFile(text);
}
catch (error) {
logger.info('Parsing remote config failed', error);
return;
}
}
export function isMissingConfigFileException(result) {
const data = result.data;
const errors = (result.error?.graphQLErrors ?? []);
const isMissingConfigError = errors.some((error) => {
return (error.path?.includes('remoteConfig') &&
error.originalError?.type === 'NOT_FOUND');
});
const isMissingConfigFileException = isMissingConfigError && data != null;
return isMissingConfigFileException;
}
//# sourceMappingURL=remote-config.js.map