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

Allow showing delta from @{push} as well as @{upstream} #395

Closed
gibfahn opened this issue Dec 25, 2019 · 2 comments
Closed

Allow showing delta from @{push} as well as @{upstream} #395

gibfahn opened this issue Dec 25, 2019 · 2 comments

Comments

@gibfahn
Copy link
Contributor

gibfahn commented Dec 25, 2019

Requires romkatv/gitstatus#89

This would be really useful for the reasons I went into here, basically because it makes things much simpler when using the GitHub Pull Request workflow.

Workaround

In case this is useful to anyone else, I currently work around it by adding the following lines to my p10k.zsh:

    local -a push_behind_ahead=(${(ps:\t:)"$(command git rev-list --left-right --count HEAD...@{push} 2>/dev/null)"})
    local VCS_STATUS_PUSH_COMMITS_AHEAD="${push_behind_ahead[1]}"
    local VCS_STATUS_PUSH_COMMITS_BEHIND="${push_behind_ahead[2]}"

    # ⇠42 if behind the @{push} branch.
    (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}"
    (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" "
    # ⇢42 if ahead of the @{push} branch; no leading space if also behind: ⇠42⇢42.
    (( VCS_STATUS_PUSH_COMMITS_AHEAD  )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}"

You want to add them under this line:

    (( VCS_STATUS_COMMITS_AHEAD  )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}"

I tried to make it match the existing code as much as possible, to the point where if the gitstatus PR was shipped and the variables defined, in theory the second chunk could be PR'd directly against the repo.

@romkatv
Copy link
Owner

romkatv commented Feb 9, 2020

This is done.

@gibfahn
Copy link
Contributor Author

gibfahn commented Feb 9, 2020

Updated and tried this and it works perfectly, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants