-
Notifications
You must be signed in to change notification settings - Fork 528
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
Parse url for base branch and pr bases #5611
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
cc6939d
to
f2681aa
Compare
f2681aa
to
c9e6f6b
Compare
c9e6f6b
to
5e9f8c5
Compare
5e9f8c5
to
afbf71a
Compare
@Caleb-T-Owens what do you think of this the |
afbf71a
to
6a0369d
Compare
- will help us compare pr base against target
6a0369d
to
8696a86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didnt properly review this but if it sucks we can fix it tomorro
@@ -0,0 +1,75 @@ | |||
import { writable, type Readable } from 'svelte/store'; | |||
|
|||
export function uniqueDerived<T>(source: Readable<T>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the class is helpful, can't we just say:
export function shallowDeduplicate<A>(store: Readable<A>): Readable<A> {
const deduplicatedStore = readable(get(store), (set) => {
let lastValue = get(store);
const unsubscribe = store.subscribe((value) => {
if (!shallowCompare(lastValue, value)) {
lastValue = value;
set(value);
}
});
return unsubscribe;
});
return deduplicatedStore;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try that out. *edit: one immediate thing I would want to avoid is subscribing to the store when creating the derived store, which happens here because of the get()
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be safe to set the readable initial value to undefined, and keep the result as Readable<T>
because the start stop notifier gets run synchronously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... or even write it as a derived to make that intent clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function shallowDeduplicate<A>(store: Readable<A>): Readable<A> {
let lastValue: undefined | A = undefined;
const deduplicatedStore = derived<Readable<A>, A>(store, (value, set) => {
if (!shallowCompare(lastValue, value)) {
lastValue = value;
set(value);
}
});
return deduplicatedStore;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AHHhhhh no... that derived version isn't safe
if (typeof left !== 'object' || typeof right !== 'object' || left === null || right === null) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined needs to be considered here
|
||
const httpRemoteUrls = ['https://github.com/user/repo.git', 'http://192.168.1.1/user/repo.git']; | ||
|
||
test.each(httpRemoteUrls)('HTTP Remote - %s', (remoteUrl) => { | ||
expect(remoteUrlIsHttp(remoteUrl)).toBe(true); | ||
}); | ||
|
||
const nonHttpRemoteUrls = [ | ||
'git@github.com:user/repo.git', | ||
'ssh://git@github.com:22/user/repo.git', | ||
'git://github.com/user/repo.git' | ||
]; | ||
|
||
test.each(nonHttpRemoteUrls)('Non HTTP Remote - %s', (remoteUrl) => { | ||
expect(remoteUrlIsHttp(remoteUrl)).toBe(false); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we want these tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they existed for exactly 1 location in the code asking "is the protocol http?". The if condition can just as well be protocol.startsWith('http')
rather than having a specialized and tested function.
I'm bothered by this. Especially when I was asked for feedback. |
This is part 1 of 2 in a stack made with GitButler: