Skip to content

Add missing header to files

Jacques Xing requested to merge add-missing-header-to-file into feature/redesign

Issue/feature addressed

Add missing header file to the redesign branch.

Proposed solution

The following bash script has been used to add missing header to all relevant files

#!/bin/bash
addHeader() {
file=$1
rm -f tmp
cat <<EOT>> tmp
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description:
//
///////////////////////////////////////////////////////////////////////////////

EOT
cat $file >> tmp
mv tmp $file
sed -i "1i //" $file
sed -i "1i // File: ${file##*/}" $file
sed -i "1i //" $file
sed -i "1i ///////////////////////////////////////////////////////////////////////////////" $file
}

for file in $(find -type f); do
    filename=${file##*/}
    if [[ ! $(grep -F "MIT License" $file) ]]; then
        if [[ "${filename##*.}" == "h" ]]; then
            echo $file does not contains MIT License
            addHeader $file
        fi
        if [[ "${filename##*.}" == "cpp" ]]; then
            echo $file does not contains MIT License
            addHeader $file
        fi
        if [[ "${filename##*.}" == "hpp" ]]; then
            echo $file does not contains MIT License
            addHeader $file
        fi
    fi
done

Implementation

Tests

Suggested reviewers

Please suggest any people who would be appropriate to review your code.

Notes

Please add any other information that could be useful for reviewers.

Checklist

  • [ ] Functions and classes, or changes to them, are documented.
  • [ ] User guide/documentation is updated.
  • [ ] Changelog is updated.
  • [ ] Suitable tests added for new functionality.
  • Contributed code is correctly formatted. (See the contributing guidelines).
  • License added to any new files.
  • No extraneous files have been added (e.g. compiler output or test data files).
Edited by Jacques Xing

Merge request reports