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

fix getOrigin type and remove safeHash support #2419

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lix/source-code/client/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type Repository = {
forkStatus: () => Promise<
{ ahead: number; behind: number; conflicts: boolean } | { error: string }
>
getOrigin: (arg?: { safeHashOnly?: boolean }) => Promise<string>
getOrigin: () => Promise<string | undefined>
getCurrentBranch: () => Promise<string | undefined>
getBranches: () => Promise<string[] | undefined>
errors: Subscribable<LixError[]>
Expand Down
10 changes: 2 additions & 8 deletions lix/source-code/client/src/openRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,20 +551,14 @@ export async function openRepository(
*
* The function ensures that the same orgin is always returned for the same repository.
*/
async getOrigin({ safeHashOnly = false } = {}): Promise<string> {
if (safeHashOnly) {
// FIXME: handle forks and upstream!
const safeOriginHash = await hash(`${lixHost}__${repoHost}__${owner}__${repoName}`)
return safeOriginHash
}

async getOrigin(): Promise<string | undefined> {
// TODO: this flow is obsolete and can be unified with the initialization of the repo
const repo = await this
const remotes: Array<{ remote: string; url: string }> | undefined = await repo.listRemotes()

const origin = remotes?.find((elements) => elements.remote === "origin")
if (origin === undefined) {
return "unknown"
return undefined
}
// polyfill for some editor related origin issues
let result = origin.url
Expand Down
Loading