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
5661c55c
Commit
5661c55c
authored
3 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
working script
parent
1a81c79d
No related branches found
Branches containing commit
No related tags found
1 merge request
!427
Resolve "Wolf license"
Pipeline
#7264
failed
3 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wolf_scripts/license_header_2022.txt
+0
-0
0 additions, 0 deletions
wolf_scripts/license_header_2022.txt
wolf_scripts/license_manager.sh
+46
-16
46 additions, 16 deletions
wolf_scripts/license_manager.sh
with
46 additions
and
16 deletions
wolf_scripts/license_
text
.txt
→
wolf_scripts/license_
header_2022
.txt
+
0
−
0
View file @
5661c55c
File moved
This diff is collapsed.
Click to expand it.
wolf_scripts/license_manager.sh
100644 → 100755
+
46
−
16
View file @
5661c55c
...
...
@@ -2,9 +2,10 @@
#options
tmp
=
false
path
=
$PWD
recursive
=
true
path
=
""
#
recursive=true
license
=
""
remove
=
false
for
i
in
"
$@
"
;
do
case
$i
in
...
...
@@ -16,38 +17,67 @@ for i in "$@"; do
path
=
"
${
i
#*=
}
"
shift
# past argument=value
;;
--non-recursive
)
recursive
=
false
shift
# past argument=value
;;
--license-file
=
*
)
--license-header
=
*
)
license
=
"
${
i
#*=
}
"
shift
# past argument=value
;;
# --non-recursive)
# recursive=false
# shift # past argument=value
# ;;
*
)
# unknown option
;;
esac
done
echo
"tmp =
${
tmp
}
"
echo
"path =
${
path
}
"
echo
"recursive =
${
recursive
}
"
echo
"license =
${
license
}
containing:"
cat
${
license
}
# check options
if
[
"
$path
"
==
""
]
;
then
echo
'Please, provide the path to the folder containing the code with --path=/my/folder/code'
exit
1
else
if
[
-d
"
$path
"
]
;
then
echo
"Valid path:
${
path
}
"
else
echo
"Error:
${
path
}
not found. Can not continue."
exit
1
fi
fi
if
[
"
$license
"
==
""
]
;
then
echo
"Error: Please, provide the path to the folder containing the code with --license-header=/my/license/header/file.txt"
exit
1
else
if
[
-f
"
$license
"
]
;
then
echo
"Valid license header file:
${
license
}
containing:"
cat
${
license
}
else
echo
"Error: License header file
${
license
}
not found. Can not continue."
exit
1
fi
fi
# PATH (AND tmp FOLDER)
folder
=
$path
if
[
$tmp
]
;
then
mkdir
-pv
${
path
}
_tmp
cp
-a
$path
/.
${
path
}
_tmp
folder
=
${
path
}
_tmp
if
$tmp
;
then
echo
"Creating temporary folder:
${
path
}
_tmp"
mkdir
-pv
${
path
}
_tmp
cp
-a
$path
/.
${
path
}
_tmp
folder
=
${
path
}
_tmp
fi
# DETECT AND REMOVE EXISTING LICENSE
#TODO
# ADD CONTENT OF license-file AT THE BEGINNING OF CODE FILES
echo
"Recursively adding license header to all files (.c, .cpp, .h, .hpp)"
for
i
in
$(
find
$folder
-name
'*.c'
-or
-name
'*.cpp'
-or
-name
'*.h'
-or
-name
'*.hpp'
)
do
if
grep
-Fxq
"//LICENSE_START"
$i
then
echo
"skippping
${
i
}
"
else
(
echo
$'//LICENSE_START
\n
'
;
cat
${
license
}
;
echo
$'
\n
//LICENSE_END
\n
'
;
cat
$i
)
>
temp_file
mv
temp_file
$i
fi
done
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