forked from renovatebot/renovate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move all Git commands behind a PlatformScm interface renova…
…tebot#19065 this is a proof of concept only...
- Loading branch information
Showing
15 changed files
with
191 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { PlatformScm } from '../types'; | ||
import { | ||
isBranchBehindBase, | ||
isBranchConflicted, | ||
isBranchModified, | ||
} from './index'; | ||
|
||
const gerritScm: Partial<PlatformScm> = { | ||
isBranchModified, | ||
isBranchBehindBase, | ||
isBranchConflicted, | ||
|
||
//branchExists: ...TODO: Problem the call needs to be async | ||
//getBranchCommit: ...TODO: Problem the call needs to be async | ||
|
||
deleteBranch: (branchName: string) => Promise.resolve(), //no-op for gerrit, there exists no remote-branches for PRs | ||
}; | ||
|
||
export default gerritScm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as _git from '../../util/git'; | ||
import gerritScm from './gerrit/scm'; | ||
import type { PlatformScm } from './types'; | ||
|
||
export const platformScmImpls = new Map<string, Partial<PlatformScm>>(); | ||
platformScmImpls.set('gerrit', gerritScm); | ||
|
||
export const defaultGitScm: PlatformScm = { | ||
isBranchBehindBase: _git.isBranchBehindBase, | ||
isBranchModified: _git.isBranchModified, | ||
isBranchConflicted: _git.isBranchConflicted, | ||
branchExists: _git.branchExists, | ||
getBranchCommit: _git.getBranchCommit, | ||
deleteBranch: _git.deleteBranch, | ||
}; | ||
|
||
const scmProxy: ProxyHandler<PlatformScm> = { | ||
get(_target: PlatformScm, prop: keyof PlatformScm, receiver: any) { | ||
if (typeof _scm[prop] !== 'undefined') { | ||
return _scm[prop]; | ||
} | ||
return Reflect.get(_target, prop, receiver); | ||
}, | ||
}; | ||
|
||
export const scm = new Proxy<PlatformScm>(defaultGitScm, scmProxy); | ||
let _scm: Partial<PlatformScm> = defaultGitScm; | ||
|
||
export function setPlatformScmApi(name: string): void { | ||
_scm = platformScmImpls.has(name) | ||
? platformScmImpls.get(name)! | ||
: defaultGitScm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.