Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
a6ea5394
Commit
a6ea5394
authored
3 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
license script with exclude option
parent
13c9bc95
No related branches found
No related tags found
1 merge request
!427
Resolve "Wolf license"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wolf_scripts/license_manager.sh
+27
-10
27 additions, 10 deletions
wolf_scripts/license_manager.sh
with
27 additions
and
10 deletions
wolf_scripts/license_manager.sh
+
27
−
10
View file @
a6ea5394
...
@@ -12,6 +12,7 @@ line_end_mark="//--------LICENSE_END--------"
...
@@ -12,6 +12,7 @@ line_end_mark="//--------LICENSE_END--------"
tmp
=
false
tmp
=
false
mode
=
"none"
mode
=
"none"
path
=
""
path
=
""
exclude_folder
=
""
#recursive=true
#recursive=true
license
=
""
license
=
""
...
@@ -45,6 +46,10 @@ for i in "$@"; do
...
@@ -45,6 +46,10 @@ for i in "$@"; do
fi
fi
shift
# past argument=value
shift
# past argument=value
;;
;;
--exclude
=
*
)
exclude_folder
=
"
${
i
#*=
}
"
shift
# past argument=value
;;
*
)
*
)
# unknown option
# unknown option
;;
;;
...
@@ -77,11 +82,19 @@ else
...
@@ -77,11 +82,19 @@ else
fi
fi
fi
fi
echo
"mode:
${
mode
}
"
if
[
"
$exclude_folder
"
==
""
]
;
then
echo
"No folders will be excluded"
else
if
[
-d
"
${
path
}
/
${
exclude_folder
}
"
]
;
then
echo
"Valid remove folder path:
${
path
}
/
${
exclude_folder
}
"
fi
fi
if
[
$mode
==
"none"
]
;
then
if
[
$mode
==
"none"
]
;
then
echo
"Error: Script should be called with one of the following options: --update or --add"
echo
"Error: Script should be called with one of the following options: --update or --add"
exit
1
exit
1
else
echo
"mode:
${
mode
}
"
fi
fi
# PATH (AND tmp FOLDER)
# PATH (AND tmp FOLDER)
...
@@ -93,30 +106,34 @@ if [ $tmp == true ]; then
...
@@ -93,30 +106,34 @@ if [ $tmp == true ]; then
folder
=
${
path
}
_tmp
folder
=
${
path
}
_tmp
fi
fi
# LIST OF FILES TO BE ITERATED ON
if
[
"
$exclude_folder
"
==
""
]
;
then
file_list
=
$(
find
$folder
-name
'*.c'
-or
-name
'*.cpp'
-or
-name
'*.h'
-or
-name
'*.hpp'
)
else
file_list
=
$(
find
$folder
-path
${
folder
}
/
${
exclude_folder
}
-prune
-name
'*.c'
-or
-name
'*.cpp'
-or
-name
'*.h'
-or
-name
'*.hpp'
)
fi
# DETECT AND REMOVE EXISTING LICENSE
# DETECT AND REMOVE EXISTING LICENSE
if
[
$mode
==
"update"
]
;
then
if
[
"
$mode
"
==
"update"
]
;
then
echo
"Recursely removing license header from all files (.c, .cpp, .h, .hpp)"
echo
"Recursely removing license header from all files (.c, .cpp, .h, .hpp)"
for
i
in
$
(
fi
nd
$folder
-name
'*.c'
-or
-name
'*.cpp'
-or
-name
'*.h'
-or
-name
'*.hpp'
)
for
i
in
$fi
le_list
do
do
if
grep
-Fxq
${
line_start_mark
}
$i
if
grep
-Fxq
${
line_start_mark
}
$i
then
then
echo
" Removing license header from file
${
i
}
"
echo
" Removing license header from file
${
i
}
"
line_start
=
"
$(
grep
-wn
$line_start_mark
${
i
}
|
head
-n
1 |
cut
-d
:
-f1
)
"
line_start
=
"
$(
grep
-wn
$line_start_mark
${
i
}
|
head
-n
1 |
cut
-d
:
-f1
)
"
line_end
=
"
$(
grep
-wn
$line_end_mark
${
i
}
|
head
-n
1 |
cut
-d
:
-f1
)
"
line_end
=
"
$(
grep
-wn
$line_end_mark
${
i
}
|
head
-n
1 |
cut
-d
:
-f1
)
"
echo
${
line_start
}
#echo ${line_start}
echo
${
line_end
}
#echo ${line_end}
#echo "${line_start},${line_end}d" $i
#sed $('${line_start},${line_end}d)' $i
awk
-v
m
=
$line_start
-v
n
=
$line_end
'm <= NR && NR <= n {next} {print}'
$i
>
tmpfile
&&
mv
tmpfile
$i
awk
-v
m
=
$line_start
-v
n
=
$line_end
'm <= NR && NR <= n {next} {print}'
$i
>
tmpfile
&&
mv
tmpfile
$i
cat
$i
#
cat $i
fi
fi
done
done
#TODO
fi
fi
# ADD CONTENT OF license-file AT THE BEGINNING OF CODE FILES
# ADD CONTENT OF license-file AT THE BEGINNING OF CODE FILES
echo
"Recursively adding license header to all files (.c, .cpp, .h, .hpp)"
echo
"Recursively adding license header to all files (.c, .cpp, .h, .hpp)"
for
i
in
$
(
fi
nd
$folder
-name
'*.c'
-or
-name
'*.cpp'
-or
-name
'*.h'
-or
-name
'*.hpp'
)
for
i
in
$fi
le_list
do
do
if
grep
-Fxq
${
line_start_mark
}
$i
;
then
if
grep
-Fxq
${
line_start_mark
}
$i
;
then
echo
"skippping
${
i
}
"
echo
"skippping
${
i
}
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment