Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
07860bc5
Commit
07860bc5
authored
Aug 30, 2014
by
Roman Inflianskas
Committed by
Bruno Pinto
Oct 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bak plugin: tabs -> spaces
parent
5b861f5c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
96 additions
and
88 deletions
+96
-88
plugins/bak/bak.load
plugins/bak/bak.load
+16
-8
plugins/bak/cpbak.fish
plugins/bak/cpbak.fish
+1
-1
plugins/bak/mvbak.fish
plugins/bak/mvbak.fish
+1
-1
plugins/bak/tests/helper.fish
plugins/bak/tests/helper.fish
+2
-2
plugins/bak/tests/test_bak.fish
plugins/bak/tests/test_bak.fish
+74
-74
plugins/bak/uncpbak.fish
plugins/bak/uncpbak.fish
+1
-1
plugins/bak/unmvbak.fish
plugins/bak/unmvbak.fish
+1
-1
No files found.
plugins/bak/bak.load
View file @
07860bc5
...
...
@@ -4,6 +4,16 @@ function __bak_help
$argv[1] SOURCE..."
end
function __bak_parse_help
function has_help_arg
# non implemented
end
if [ (count $argv) -lt 3 ]; or has_help_arg $argv
__bak_help $argv[1]
end
end
function __bak_name
# trim / for directories
set file (echo $argv[1] | sed 's/\/$//')
...
...
@@ -11,13 +21,12 @@ function __bak_name
end
function __bak
set program $argv[2]
if [ (count $argv) -gt 2 ]
__bak_parse_help $argv
or begin
set program $argv[2]
for file in $argv[3..-1]
eval $program $file (__bak_name $file)
end
else
__bak_help $argv[1]
end
end
...
...
@@ -34,8 +43,9 @@ function __bak_normalized
end
function __unbak
set program $argv[2]
if [ (count $argv) -gt 2 ]
__bak_parse_help $argv
or begin
set program $argv[2]
for file in $argv[3..-1]
set normalized (__bak_normalized $file)
if test ! -e $file
...
...
@@ -48,7 +58,5 @@ function __unbak
eval $program $file $normalized
end
end
else
__bak_help $argv[1]
end
end
plugins/bak/cpbak.fish
View file @
07860bc5
# Function to copy files and directories (a.txt copy to a.txt.20140608_195859.bak)
# (c) Roman Inflianskas (rominf) <infroma@gmail.com>, 2014
function cpbak
function cpbak
--description 'Copy files to make a backup copies'
__bak cpbak 'cp -a' $argv
end
plugins/bak/mvbak.fish
View file @
07860bc5
# Function to rename files and directories (a.txt rename to a.txt.20140608_195859.bak)
# (c) Roman Inflianskas (rominf) <infroma@gmail.com>, 2014
function mvbak
function mvbak
--description 'Rename files to make a backup copies'
__bak mvbak mv $argv
end
plugins/bak/tests/helper.fish
View file @
07860bc5
set -l fish_tank /usr/local/share/fish-tank/tank.fish
if not test -e $fish_tank
echo 'error: fish-tank is required to run these tests (https://github.com/terlar/fish-tank)'
exit 1
echo 'error: fish-tank is required to run these tests (https://github.com/terlar/fish-tank)'
exit 1
end
source $fish_tank
...
...
plugins/bak/tests/test_bak.fish
View file @
07860bc5
function suite_bak
function setup
return 0
end
function setup
return 0
end
function teardown
rm -rf $test_dir/*
end
function teardown
rm -rf $test_dir/*
end
function test_is_bak
assert (__is_bak '.ccnet.20140817_234302.bak')
assert (__is_bak 'file with spaces.20140817_234302.bak')
assert (not __is_bak '.ccnet.bak')
end
function test_is_bak
assert (__is_bak '.ccnet.20140817_234302.bak')
assert (__is_bak 'file with spaces.20140817_234302.bak')
assert (not __is_bak '.ccnet.bak')
end
function test_normalized
assert_equal '.ccnet' (__bak_normalized '.ccnet.20140817_234302.bak')
assert_equal 'file with spaces' (__bak_normalized 'file with spaces.20140817_234302.bak')
end
function test_mv_single
touch a
mvbak a
assert __is_bak (ls)
end
function test_normalized
assert_equal '.ccnet' (__bak_normalized '.ccnet.20140817_234302.bak')
assert_equal 'file with spaces' (__bak_normalized 'file with spaces.20140817_234302.bak')
end
function test_mv_single
touch a
mvbak a
assert __is_bak (ls)
end
function test_mv_multiple
touch a b
mvbak a b
for f in (ls)
assert __is_bak $f
end
end
function test_mv_multiple
touch a b
mvbak a b
for f in (ls)
assert __is_bak $f
end
end
function test_unmv_single
touch a
mvbak a
unmvbak (ls)
assert_equal a (ls)
end
function test_unmv_single
touch a
mvbak a
unmvbak (ls)
assert_equal a (ls)
end
function test_unmv_multiple
set files (seq 4)
touch $files
mvbak $files
unmvbak (ls)
assert_equal "$files" (ls)
end
function test_unmv_multiple
set files (seq 4)
touch $files
mvbak $files
unmvbak (ls)
assert_equal "$files" (ls)
end
function test_cp_single
touch a
cpbak a
assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort)
end
function test_cp_single
touch a
cpbak a
assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort)
end
function test_cp_multiple
set files (seq 4)
touch $files
cpbak $files
for f in $files
set files_bak "$files_bak\n"(__bak_name $f)
end
set expected (begin; echo $files | sed 's/ /\n/g'; echo -e $files_bak; end | sort | grep -v '^$')
assert_equal "$expected" (ls | sort)
end
function test_cp_multiple
set files (seq 4)
touch $files
cpbak $files
for f in $files
set files_bak "$files_bak\n"(__bak_name $f)
end
set expected (begin; echo $files | sed 's/ /\n/g'; echo -e $files_bak; end | sort | grep -v '^$')
assert_equal "$expected" (ls | sort)
end
function test_uncp_single
touch a
cpbak a
rm a
uncpbak (ls)
assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort)
end
function test_uncp_single
touch a
cpbak a
rm a
uncpbak (ls)
assert_equal (echo -e 'a' (__bak_name a) | sort) (ls | sort)
end
function test_cp_multiple
set files (seq 4)
touch $files
cpbak $files
rm $files
uncpbak (ls)
for f in $files
set files_bak "$files_bak\n"(__bak_name $f)
end
set expected (begin; echo $files | sed 's/ /\n/g'; echo -e $files_bak; end | sort | grep -v '^$')
end
function test_cp_multiple
set files (seq 4)
touch $files
cpbak $files
rm $files
uncpbak (ls)
for f in $files
set files_bak "$files_bak\n"(__bak_name $f)
end
set expected (begin; echo $files | sed 's/ /\n/g'; echo -e $files_bak; end | sort | grep -v '^$')
end
end
if not set -q tank_running
...
...
plugins/bak/uncpbak.fish
View file @
07860bc5
# Function to copy files and directories (a.txt.20140608_195859.bak copy to a.txt)
# (c) Roman Inflianskas (rominf) <infroma@gmail.com>, 2014
function uncpbak
function uncpbak
--description 'Copy files to revert a backup copies to a normal files'
__unbak uncpbak 'cp -a' $argv
end
plugins/bak/unmvbak.fish
View file @
07860bc5
# Function to move files and directories (a.txt.20140608_195859.bak move to a.txt)
# (c) Roman Inflianskas (rominf) <infroma@gmail.com>, 2014
function unmvbak
function unmvbak
--description 'Move files to revert a backup copies to a normal files'
__unbak unmvbak mv $argv
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment