-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Allow creating an alias for repositories #12000
Conversation
// No need to update the recent repositories if the selected repository is | ||
// the same as the old one (this could happen when the alias of the selected | ||
// repository is changed). | ||
if (previousRepositoryId === currentRepositoryId) { | ||
return | ||
} |
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.
Without this, creating/changing/removing the alias of the current repo, would move the current repo into the Recents list, which doesn't make sense.
@@ -132,6 +133,7 @@ export class RepositoriesStore extends TypedBaseStore< | |||
? await this.findGitHubRepositoryByID(repo.gitHubRepositoryID) | |||
: await Promise.resolve(null), // Dexie gets confused if we return null | |||
repo.missing, | |||
enableRepositoryAliases() ? repo.alias : null, |
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.
This prevents the alias from being loaded from persistence, so we can forget about checking the feature flag in many other places 😅
icon = iconForRepository(repository) | ||
title = repository.name | ||
title = alias ?? repository.name |
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.
This is the title of the drop down that shows the current repository.
@@ -89,7 +89,7 @@ export function groupRepositories( | |||
const { aheadBehind, changedFilesCount } = | |||
localRepositoryStateLookup.get(r.id) || fallbackValue | |||
const repositoryText = | |||
r instanceof Repository ? [r.name, nameOf(r)] : [r.name] | |||
r instanceof Repository ? [r.alias ?? r.name, nameOf(r)] : [r.name] |
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.
This basically makes sure the alias is used to look for matches when the user filters the repository list.
const repositoryText = | ||
repository instanceof Repository | ||
? [repository.name, nameOf(repository)] | ||
? [repositoryAlias ?? repository.name, nameOf(repository)] |
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.
This is also for the repository list filter.
const existingCount = names.get(repository.name) || 0 | ||
names.set(repository.name, existingCount + 1) | ||
const alias = repository instanceof Repository ? repository.alias : null | ||
const name = alias ?? repository.name | ||
const existingCount = names.get(name) || 0 | ||
names.set(name, existingCount + 1) |
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.
This list of names is used to detect duplicates in the Recents
group, to know when we need to disambiguate showing the owner as a prefix (e.g. github/desktop
).
In this change I'm just adding the alias instead of the repo name, when available.
const nameCount = names.get(repository.name) || 0 | ||
const nameCount = names.get(repositoryAlias ?? repository.name) || 0 |
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.
This is where we actually check if the repo alias or name is duplicated and need disambiguation.
private buildAliasMenuItems(): ReadonlyArray<IMenuItem> { | ||
const repository = this.props.repository | ||
|
||
if (!(repository instanceof Repository) || !enableRepositoryAliases()) { |
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.
Just curious.. is there a time that it is not an instance of a Repository?
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.
Hmmm.. just realized there is a type of Repositoryish. Which made me laugh... But I see that evidently it can be cloning one.
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.
✨ This is awesome! Though it is a pretty straight forward PR. I really appreciate all your PR comments along the way - makes reading through it a breeze. Tested it out and it is slick.
Only thing I came across which I don't think causes any harm - just a UI quirk. I can make the alias as long as I want, but I can only ever see so many characters and when I saw the ellipsis, I automatically tried to hover over it to see the rest of the alias. This likely not something people will do tho.. and if they do.. they can change it. 🤷
Thank you for your feedback! ❤️ The thing about the long aliases and not being able to see it in the tooltip is a good point, but also true that they can just change it 😆 I'll raise it in the next sync meeting. |
Thank you thank you thank you thank you <3<3<3 |
This is part of #7856
Description
This PR adds initial support to create alias for repositories:
Screenshots
repo-alias-demo.mov
Release notes
Notes: [New] Add an alias to your repos and name them however you want!