Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Separate Targets Repo #566

Merged
merged 7 commits into from
Oct 23, 2023
32 changes: 32 additions & 0 deletions graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,38 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "targetsRepoSrcFolder",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "targetsRepoUrl",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "url",
"description": null,
Expand Down
12 changes: 11 additions & 1 deletion src/api/src/graphql/inputs/GitRepositoryInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@ export default class GitRepository {
@Field()
srcFolder: string;

@Field()
targetsRepoUrl: string;

@Field()
targetsRepoSrcFolder: string;

constructor(
url: string,
owner: string,
repositoryName: string,
rawRepoUrl: string,
srcFolder: string
srcFolder: string,
targetsRepoUrl: string,
targetsRepoSrcFolder: string
) {
this.url = url;
this.owner = owner;
this.repositoryName = repositoryName;
this.rawRepoUrl = rawRepoUrl;
this.srcFolder = srcFolder;
this.targetsRepoUrl = targetsRepoUrl;
this.targetsRepoSrcFolder = targetsRepoSrcFolder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { removeDirectoryContents } from '../../FlashingStrategyLocator/artefacts
export interface GitRepository {
url: string;
srcFolder: string;
targetsRepoUrl: string;
targetsRepoSrcFolder: string;
}

export interface FirmwareVersion {
Expand Down Expand Up @@ -158,26 +160,41 @@ export default class DeviceDescriptionsLoader {
);

const srcFolder =
gitRepository.srcFolder === '/' ? '' : `${gitRepository.srcFolder}/`;
gitRepository.targetsRepoSrcFolder === '/'
? ''
: `${gitRepository.targetsRepoSrcFolder}/`;

if (
gitRepository.targetsRepoUrl.toLowerCase() ===
'https://github.com/ExpressLRS/targets'.toLowerCase()
) {
const branchResult = await firmwareDownload.checkoutBranch(
gitRepository.targetsRepoUrl,
srcFolder,
'master'
);
return branchResult.path;
}

switch (args.source) {
case FirmwareSource.GitBranch:
const branchResult = await firmwareDownload.checkoutBranch(
gitRepository.url,
`${srcFolder}hardware`,
gitRepository.targetsRepoUrl,
srcFolder,
args.gitBranch
);
return branchResult.path;
case FirmwareSource.GitCommit:
const commitResult = await firmwareDownload.checkoutCommit(
gitRepository.url,
`${srcFolder}hardware`,
gitRepository.targetsRepoUrl,
srcFolder,
args.gitCommit
);
return commitResult.path;
case FirmwareSource.GitTag:
const tagResult = await firmwareDownload.checkoutTag(
gitRepository.url,
`${srcFolder}hardware`,
gitRepository.targetsRepoUrl,
srcFolder,
args.gitTag
);
return tagResult.path;
Expand All @@ -186,8 +203,8 @@ export default class DeviceDescriptionsLoader {
throw new Error('empty GitPullRequest head commit hash');
}
const prResult = await firmwareDownload.checkoutCommit(
gitRepository.url,
`${srcFolder}hardware`,
gitRepository.targetsRepoUrl,
srcFolder,
args.gitPullRequest.headCommitHash
);
return prResult.path;
Expand Down
2 changes: 2 additions & 0 deletions src/api/src/services/BinaryFlashingStrategy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ export default class BinaryFlashingStrategyService implements FlashingStrategy {
{
url: gitRepositoryUrl,
srcFolder: gitRepositorySrcFolder,
targetsRepoUrl: gitRepository.targetsRepoUrl,
targetsRepoSrcFolder: gitRepository.targetsRepoSrcFolder,
}
);

Expand Down
4 changes: 4 additions & 0 deletions src/ui/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const Config: IConfig = {
rawRepoUrl: 'https://raw.githubusercontent.com/ExpressLRS/ExpressLRS',
srcFolder: 'src',
tagExcludes: ['<2.5.0'],
targetsRepoUrl: 'https://github.com/ExpressLRS/targets',
targetsRepoSrcFolder: '/',
},
backpackGit: {
cloneUrl: 'https://github.com/ExpressLRS/Backpack',
Expand All @@ -33,6 +35,8 @@ export const Config: IConfig = {
rawRepoUrl: 'https://raw.githubusercontent.com/ExpressLRS/Backpack',
srcFolder: '/',
tagExcludes: [],
targetsRepoUrl: 'https://github.com/ExpressLRS/Backpack',
jurgelenas marked this conversation as resolved.
Show resolved Hide resolved
targetsRepoSrcFolder: 'hardware',
},
};

Expand Down
2 changes: 2 additions & 0 deletions src/ui/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export type GitRepositoryInput = {
readonly rawRepoUrl: Scalars['String'];
readonly repositoryName: Scalars['String'];
readonly srcFolder: Scalars['String'];
readonly targetsRepoSrcFolder: Scalars['String'];
readonly targetsRepoUrl: Scalars['String'];
readonly url: Scalars['String'];
};

Expand Down
4 changes: 4 additions & 0 deletions src/ui/models/GitRepository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export default interface GitRepository {
srcFolder: string;

tagExcludes: string[];

targetsRepoUrl: string;

targetsRepoSrcFolder: string;
}
8 changes: 8 additions & 0 deletions src/ui/views/ConfiguratorView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ const ConfiguratorView: FunctionComponent<ConfiguratorViewProps> = (props) => {
repositoryName: gitRepository.repositoryName,
rawRepoUrl: gitRepository.rawRepoUrl,
srcFolder: gitRepository.srcFolder,
targetsRepoUrl: gitRepository.targetsRepoUrl,
targetsRepoSrcFolder: gitRepository.targetsRepoSrcFolder,
},
},
});
Expand Down Expand Up @@ -351,6 +353,8 @@ const ConfiguratorView: FunctionComponent<ConfiguratorViewProps> = (props) => {
repositoryName: gitRepository.repositoryName,
rawRepoUrl: gitRepository.rawRepoUrl,
srcFolder: gitRepository.srcFolder,
targetsRepoUrl: gitRepository.targetsRepoUrl,
targetsRepoSrcFolder: gitRepository.targetsRepoSrcFolder,
},
},
});
Expand Down Expand Up @@ -467,6 +471,8 @@ const ConfiguratorView: FunctionComponent<ConfiguratorViewProps> = (props) => {
repositoryName: gitRepository.repositoryName,
rawRepoUrl: gitRepository.rawRepoUrl,
srcFolder: gitRepository.srcFolder,
targetsRepoUrl: gitRepository.targetsRepoUrl,
targetsRepoSrcFolder: gitRepository.targetsRepoSrcFolder,
},
},
});
Expand Down Expand Up @@ -634,6 +640,8 @@ const ConfiguratorView: FunctionComponent<ConfiguratorViewProps> = (props) => {
repositoryName: gitRepository.repositoryName,
rawRepoUrl: gitRepository.rawRepoUrl,
srcFolder: gitRepository.srcFolder,
targetsRepoUrl: gitRepository.targetsRepoUrl,
targetsRepoSrcFolder: gitRepository.targetsRepoSrcFolder,
},
},
});
Expand Down
Loading