-
-
Notifications
You must be signed in to change notification settings - Fork 807
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
If abbreviating git dir, display correct path on a bare repo #797
Open
RexTremendae
wants to merge
1
commit into
dahlbyk:master
Choose a base branch
from
RexTremendae:abbrevFix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 suppose we should clarify what's expected here. As far as I can tell from my testing, this doesn't actually change behavior - I get this same display before and after:
I could argue that it should show
posh-git.git: [BARE:master]>
instead ofTemp:posh-git.git
.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.
Yes, that's the idea of the PR. I get a different behavior when I compare current master (just updated today) with this PR (which now is rebased onto master):
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.
Ah, the difference is my bare repo has a
.git
suffix but yours does not:Maybe we should check
(Split-Path $gitDir -Leaf) -eq '.git'
instead ofEndsWith()
?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.
Right you are...
Thinking a little bit more about it, I think my solution is a little bit over-simplified. Maybe the correct solution would be to base the logic on the same information that casues the "BARE:" label to appear? However, I cannot see that information being stored anywhere other than in the branch specifier after the function
Get-GitBranch
has completed.I really don't have the full overview of how all the functions work together in the code base; maybe it is possible to receive this information somehow?
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're right, we only store
BARE
/GIT_DIR
in the branch name at the moment. We could definitely tack those onto$GitStatus
with a bit of refactoring, but we'd also have to rearrange quite a bit to make$GitStatus
available at the point where we're callingGet-PromptPath
.Let's just check for a
.git
exact match for now. If we get feedback that it's insufficient, we can revisit.I don't know that we have an overview written up anywhere, but that would definitely be good to have. In short:
prompt
with$GitPromptScriptBlock
posh-git/src/posh-git.psm1
Line 31 in b0cbffb
$GitPromptScriptBlock
builds the actual prompt mostly by expanding strings defined in$global:GitPromptSettings
posh-git/src/PoshGitTypes.ps1
Line 225 in b0cbffb
Get-PromptPath
is calledposh-git/src/PoshGitTypes.ps1
Line 280 in b0cbffb
posh-git/src/posh-git.psm1
Line 61 in 5ce5422
Write-GitStatus
viaWrite-VcsStatus
(added to support posh-hg long ago)posh-git/src/GitPrompt.ps1
Line 202 in b0cbffb
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.
Great, thanks for the walk-through!