pull/4991/head
Your Name 4 months ago
parent ebd1f3660c
commit 770ea4b1c0
  1. 27
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 28
      apps/remixdesktop/src/plugins/isoGitPlugin.ts
  3. 35
      libs/remix-git/src/isogit.ts

@ -301,32 +301,7 @@ class DGitProvider extends Plugin<any, CustomRemixApi> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'compareBranches', { branch, remote })
}
// Get current branch commits
const headCommits = await git.log({
...await this.addIsomorphicGitConfigFS(),
ref: branch.name,
});
// Get remote branch commits
const remoteCommits = await git.log({
...await this.addIsomorphicGitConfigFS(),
ref: `${remote.name}/${branch.name}`,
});
// Convert arrays of commit objects to sets of commit SHAs
const headCommitSHAs = new Set(headCommits.map(commit => commit.oid));
const remoteCommitSHAs = new Set(remoteCommits.map(commit => commit.oid));
// Filter out commits that are only in the remote branch
const uniqueRemoteCommits = remoteCommits.filter(commit => !headCommitSHAs.has(commit.oid));
// filter out commits that are only in the local branch
const uniqueHeadCommits = headCommits.filter(commit => !remoteCommitSHAs.has(commit.oid));
return {
uniqueHeadCommits,
uniqueRemoteCommits,
};
return await isoGit.compareBranches({ branch, remote }, await this.addIsomorphicGitConfigFS())
}
async getCommitChanges(commitHash1: string, commitHash2: string): Promise<commitChange[]> {

@ -390,33 +390,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async compareBranches({ branch, remote }: compareBranchesInput): Promise<branchDifference> {
// Get current branch commits
const headCommits = await git.log({
...await this.getGitConfig(),
ref: branch.name,
});
// Get remote branch commits
const remoteCommits = await git.log({
...await this.getGitConfig(),
ref: `${remote.name}/${branch.name}`,
});
// Convert arrays of commit objects to sets of commit SHAs
const headCommitSHAs = new Set(headCommits.map(commit => commit.oid));
const remoteCommitSHAs = new Set(remoteCommits.map(commit => commit.oid));
// Filter out commits that are only in the remote branch
const uniqueRemoteCommits = remoteCommits.filter(commit => !headCommitSHAs.has(commit.oid));
// filter out commits that are only in the local branch
const uniqueHeadCommits = headCommits.filter(commit => !remoteCommitSHAs.has(commit.oid));
return {
uniqueHeadCommits,
uniqueRemoteCommits,
};
return await isoGit.compareBranches({ branch, remote }, await this.getGitConfig())
}
}

@ -1,4 +1,4 @@
import { branch, commitChange, currentBranchInput, isoGitConfig, remote } from "@remix-api"
import { branch, commitChange, compareBranchesInput, currentBranchInput, isoGitConfig, remote } from "@remix-api"
import git from 'isomorphic-git'
const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitConfig ) => {
@ -120,9 +120,40 @@ const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitCon
return result
}
const compareBranches = async ({ branch, remote }: compareBranchesInput, defaultConfig: isoGitConfig) => {
// Get current branch commits
const headCommits = await git.log({
...defaultConfig,
ref: branch.name,
});
// Get remote branch commits
const remoteCommits = await git.log({
...defaultConfig,
ref: `${remote.name}/${branch.name}`,
});
// Convert arrays of commit objects to sets of commit SHAs
const headCommitSHAs = new Set(headCommits.map(commit => commit.oid));
const remoteCommitSHAs = new Set(remoteCommits.map(commit => commit.oid));
// Filter out commits that are only in the remote branch
const uniqueRemoteCommits = remoteCommits.filter(commit => !headCommitSHAs.has(commit.oid));
// filter out commits that are only in the local branch
const uniqueHeadCommits = headCommits.filter(commit => !remoteCommitSHAs.has(commit.oid));
return {
uniqueHeadCommits,
uniqueRemoteCommits,
};
}
export const isoGit = {
currentbranch,
remotes,
branches,
getCommitChanges
getCommitChanges,
compareBranches
}
Loading…
Cancel
Save