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 compatibility with fish 3 #91

Merged
merged 2 commits into from
Dec 9, 2018
Merged
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
6 changes: 3 additions & 3 deletions conf.d/pure.fish
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ function pre_prompt --on-event fish_prompt
end

# Check if is on a Git repository
set -l is_git_repository (command git rev-parse --is-inside-work-tree ^/dev/null)
set -l is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null)

if test -n "$is_git_repository"
set git_branch_name (__parse_git_branch)

# Check if there are files to commit
set -l is_git_dirty (command git status --porcelain --ignore-submodules ^/dev/null)
set -l is_git_dirty (command git status --porcelain --ignore-submodules 2>/dev/null)

if test -n "$is_git_dirty"
set git_dirty $pure_symbol_git_dirty
end

# Check if there is an upstream configured
command git rev-parse --abbrev-ref '@{upstream}' >/dev/null ^&1; and set -l has_upstream
command git rev-parse --abbrev-ref '@{upstream}' >/dev/null 2>&1; and set -l has_upstream
if set -q has_upstream
command git rev-list --left-right --count 'HEAD...@{upstream}' | read -la git_status

Expand Down
8 changes: 4 additions & 4 deletions functions/__format_time.fish
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function __format_time -d "Format milliseconds to a human readable format"
set -l milliseconds $argv[1]
set -l seconds (math "$milliseconds / 1000 % 60")
set -l minutes (math "$milliseconds / 60000 % 60")
set -l hours (math "$milliseconds / 3600000 % 24")
set -l days (math "$milliseconds / 86400000")
set -l seconds (math -s0 "$milliseconds / 1000 % 60")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind using long option format in order to make code less cryptic and easier to contribute to?

Suggested change
set -l seconds (math -s0 "$milliseconds / 1000 % 60")
set -l seconds (math --scale=0 "$milliseconds / 1000 % 60")

Copy link
Contributor Author

@faho faho Dec 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't, because fish 2.4.0's math actually does not support that. So that would bump the required version to 2.7.0 (the first (and only) version of math to use argparse).

set -l minutes (math -s0 "$milliseconds / 60000 % 60")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -l minutes (math -s0 "$milliseconds / 60000 % 60")
set -l minutes (math --scale=0 "$milliseconds / 60000 % 60")

set -l hours (math -s0 "$milliseconds / 3600000 % 24")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -l hours (math -s0 "$milliseconds / 3600000 % 24")
set -l hours (math --scale=0 "$milliseconds / 3600000 % 24")

set -l days (math -s0 "$milliseconds / 86400000")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -l days (math -s0 "$milliseconds / 86400000")
set -l days (math --scale=0 "$milliseconds / 86400000")

set -l time
set -l threshold $argv[2]

Expand Down
2 changes: 1 addition & 1 deletion functions/__parse_git_branch.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function __parse_git_branch -d "Parse current Git branch name"
command git symbolic-ref --short HEAD ^/dev/null;
command git symbolic-ref --short HEAD 2>/dev/null;
or echo (command git show-ref --head -s --abbrev HEAD)[1]
end