pull/5370/head
Your Name 5 months ago
parent 67526d338c
commit 729aeb664f
  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())) { if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'compareBranches', { branch, remote }) return await this.call('isogit', 'compareBranches', { branch, remote })
} }
// Get current branch commits return await isoGit.compareBranches({ branch, remote }, await this.addIsomorphicGitConfigFS())
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,
};
} }
async getCommitChanges(commitHash1: string, commitHash2: string): Promise<commitChange[]> { async getCommitChanges(commitHash1: string, commitHash2: string): Promise<commitChange[]> {

@ -390,33 +390,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
} }
async compareBranches({ branch, remote }: compareBranchesInput): Promise<branchDifference> { async compareBranches({ branch, remote }: compareBranchesInput): Promise<branchDifference> {
return await isoGit.compareBranches({ branch, remote }, await this.getGitConfig())
// 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,
};
} }
} }

@ -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' import git from 'isomorphic-git'
const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitConfig ) => { const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitConfig ) => {
@ -120,9 +120,40 @@ const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitCon
return result 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 = { export const isoGit = {
currentbranch, currentbranch,
remotes, remotes,
branches, branches,
getCommitChanges getCommitChanges,
compareBranches
} }
Loading…
Cancel
Save