Edgewall Software
Modify

Opened 14 years ago

Closed 6 years ago

Last modified 4 years ago

#9567 closed task (fixed)

Script to update Trac copyright date in license header of source files

Reported by: anonymous Owned by: Ryan J Ollos
Priority: low Milestone: 1.0.18
Component: project Version:
Severity: minor Keywords: bitesized
Cc: Thijs Triemstra Branch:
Release Notes:
API Changes:

Added Makefile formula for updating file copyright dates.

Internal Changes:

Description

Copyright © 2003-2008 Edgewall Software All rights reserved.

http://trac.edgewall.org/wiki/TracLicense

update this :)

Attachments (1)

2011.patch (1.3 KB ) - added by Thijs Triemstra 13 years ago.
update user-visible copyright for 2011

Download all attachments as: .zip

Change History (32)

comment:1 by Remy Blank, 14 years ago

Milestone: not applicable

Done, thanks. We should probably also update all source files.

comment:2 by Thijs Triemstra <lists@…>, 13 years ago

Cc: lists@… added
Summary: Trac License ¶Trac License

comment:3 by Remy Blank, 13 years ago

Only if the patch contains a script that automates the process on the source files :)

comment:4 by Thijs Triemstra <lists@…>, 13 years ago

Summary: Trac LicenseScript to update Trac copyright date in license header of source files

Adding more details to summary.

by Thijs Triemstra, 13 years ago

Attachment: 2011.patch added

update user-visible copyright for 2011

comment:5 by Thijs Triemstra, 13 years ago

Cc: Thijs Triemstra added; lists@… removed
Milestone: not applicable0.12.2

Can the attached patch be applied to 0.12.2 before it's released?

comment:6 by Thijs Triemstra, 13 years ago

And TracLicense needs an update (I can't edit it).

in reply to:  5 comment:7 by Remy Blank, 13 years ago

Replying to thijstriemstra:

Can the attached patch be applied to 0.12.2 before it's released?

TracLicense was updated. The user-visible copyright years have been updated in [10502]. As for the copyrights at the top of the files, I would still prefer having a script that automates the process, to be placed in contrib.

comment:8 by Thijs Triemstra, 13 years ago

Milestone: 0.12.2not applicable

Moving it back to it's old milestone.

comment:9 by Christian Boos, 12 years ago

Priority: highestlow
Severity: criticalminor

comment:10 by Ryan J Ollos, 11 years ago

Cc: Ryan J Ollos added

comment:11 by Ryan J Ollos, 10 years ago

Cc: Ryan J Ollos removed
Milestone: not applicable1.0.3
Owner: set to Ryan J Ollos
Status: newassigned

comment:12 by Ryan J Ollos, 9 years ago

Milestone: 1.0.3next-stable-1.0.x
Owner: Ryan J Ollos removed
Status: assignednew

comment:13 by Ryan J Ollos, 9 years ago

Milestone: next-stable-1.0.xnext-major-releases

comment:14 by figaro, 8 years ago

Keywords: bitesized added

comment:15 by Ryan J Ollos, 6 years ago

Milestone: next-major-releases1.0.18

Here is a sed one-liner for updating py files copyright to YEAR:

$ YEAR=2018 find . -name "*.py" -type f -exec sed -i '' 's/^\(# Copyright .*20[01][0-9]-\)\(20[01][0-9]\)\( Edgewall\)/\1'$YEAR'\3/g' {} \;

comment:16 by Ryan J Ollos, 6 years ago

Updated headers on 1.0-stable in r16770, merged in r16771 and r16773. We can adjust the headers or regex if there are any missed updates. Still to do, edits for other file types (html, js, …).

comment:17 by Ryan J Ollos, 6 years ago

Owner: set to Ryan J Ollos
Status: newassigned

comment:18 by Ryan J Ollos, 6 years ago

API Changes: modified (diff)

Proposed changes:

  • Makefile

    diff --git a/Makefile b/Makefile
    index 2742b2b6a..35356de85 100644
    a b define HELP_release  
    586586  release-clean       remove the packages
    587587
    588588  update-help         fetches latest help/guide from Edgewall
     589  update-copyright    update copyright year in file headers
    589590  checksum            MD5 and SHA1 checksums of packages of given version
    590591  upload              scp the packages of given version to user@lynx:~/dist
    591592
    endef  
    595596export HELP_release
    596597
    597598.PHONY: release release-src wheel dist release-exe wininst
    598 .PHONY: release-clean checksum update-help upload
     599.PHONY: release-clean checksum update-copyright update-help upload
    599600
    600601ifeq "$(OS)" "Windows_NT"
    601602release: release-exe
    else  
    664665       )
    665666endif
    666667
     668copyright_re := "s/^($$PREFIX)(Copyright \(C\) 20[01][0-9])(-20[01][0-9])?$\
     669    ( Edgewall Software)/\1\2-$(year)\4/g"
     670
     671update-copyright:
     672ifeq "$(year)" ""
     673       $(error "specify year= on the make command-line")
     674else
     675       @PREFIX="<!--!  "; find . -type f -name "*.html" \
     676           -exec sed -i '' -E $(copyright_re) {} \;
     677       @PREFIX="\# "; find . -type f \
     678           \( -name "*.py" -o -name "*.ps1" -o -name "*.cgi" -o -name "*.fcgi" \) \
     679           -exec sed -i '' -E $(copyright_re) {} \;
     680       @PREFIX="\# "; sed -i '' -E $(copyright_re) \
     681           contrib/trac-svn-hook contrib/trac-pre-commit-hook
     682       @PREFIX=":: "; sed -i '' -E $(copyright_re) \
     683           contrib/trac-svn-post-commit-hook.cmd
     684       @PREFIX=; sed -i '' -E $(copyright_re) COPYING
     685endif
     686
    667687update-help:
    668688       @python contrib/checkwiki.py -d --prefix=$(prefix)
    669689       @python contrib/wiki2rst.py TracUpgrade > UPGRADE

Let me know if you notice any other files that need an update of the year in the file header.

DONE Update TracDev/ReleaseChecklist#Otherrepositoryfiles.

Last edited 6 years ago by Ryan J Ollos (previous) (diff)

comment:19 by Ryan J Ollos, 6 years ago

Resolution: fixed
Status: assignedclosed

Makefile changes committed in [16809:16811].

File header changes in [16812:16814].

comment:20 by Ryan J Ollos, 6 years ago

For reference, I used the trick in SO:50863019/121694 to split the copyright_re regex across multiple lines. There are some warnings about using the undocumented/undefined behavior, but if this fails in the future it will be easy to modify.

comment:21 by anonymous, 6 years ago

How about a python contrib/update-copyright.py based on SO?

in reply to:  21 comment:22 by Jun Omae, 5 years ago

Replying to anonymous:

How about a python contrib/update-copyright.py based on SO?

+1. The -i option of sed is not portable between BSD sed and GNU sed.

$ sed --version | head -1
sed (GNU sed) 4.2.2
$ make update-copyright year=2019
sed: can't read s/^(<!--!  )(Copyright \(C\) 20[01][0-9])(-20[01][0-9])?( Edgewall Software)$/\1\2-2019\4/g: No such file or directory
...
sed: can't read s/^(\# )(Copyright \(C\) 20[01][0-9])(-20[01][0-9])?( Edgewall Software)$/\1\2-2019\4/g: No such file or directory
Makefile:675: recipe for target 'update-copyright' failed
make: *** [update-copyright] Error 2

Other suggestions:

  1. Copyright years in *.po files should be replaced.
  2. In addition, I think it is good that copyright years in about.html and console.py would be replaced by update-copyright task.

comment:23 by Ryan J Ollos, 5 years ago

The suggestions and porting to Python sound good to me, but I'm probably not going to spend any more time on this in the near future since the sed in the makefile gets the job done for me on OSX and there are numerous other things to work on.

comment:24 by Jun Omae, 5 years ago

I tried compatibility fix without porting to Python script, [aa4a860a8/jomae.git] (jomae.git@t9567.1). Tested with OSX 10.14.3 and Ubuntu 16.04.5.

comment:25 by Ryan J Ollos, 5 years ago

Those changes work well for me on OSX 10.14.3. Thanks for fixing the issue.

Edited TracDev/ReleaseChecklist@137.

comment:26 by Jun Omae, 5 years ago

Thanks. Committed in [16889-16891].

comment:27 by Ryan J Ollos, 4 years ago

make update-copyright needs to adapt to Jinja2 templates. I'll push the change later.

  • Makefile

    diff --git a/Makefile b/Makefile
    index cd4c5a4cc..bef73981e 100644
    a b else  
    776776             && echo 1), \
    777777           sed --in-place= -r -e, \
    778778           sed -i '' -E))
    779        @PREFIX="<!--!  "; find . -type f -name "*.html" \
     779       @PREFIX="<!--!\s+"; find . -type f -name "*.html" \
     780           -exec $(SED) $(copyright_re) {} \;
     781       @PREFIX="\{\#\s+"; find . -type f -name "*.html" \
    780782           -exec $(SED) $(copyright_re) {} \;
    781783       @PREFIX="\# "; find . -type f \
    782784           \( -name "*.py" -o -name "*.po" -o -name "*.pot" -o \
Last edited 4 years ago by Ryan J Ollos (previous) (diff)

comment:28 by Ryan J Ollos, 4 years ago

comment:27 change committed to 1.4-stable in r17292, merged to trunk in r17293.

comment:29 by Ryan J Ollos, 4 years ago

Copyright line of trunk/contrib/trac-svn-post-commit-hook.cmd@17023 isn't getting updated when running make update-copyright on OSX. The svn:eol-style is CRLF (11490). Options:

  1. Change svn:eol-style to native.
  2. Modify the regex:
    • Makefile

      diff --git a/Makefile b/Makefile
      index bef73981e..1e2117ac2 100644
      a b else  
      765765endif
      766766
      767767copyright_re := "s/^($$PREFIX)(Copyright \(C\) 20[0-9][0-9])(-20[0-9][0-9])?$\
      768     ( Edgewall Software)$$/\1\2-$(year)\4/g"
       768    ( Edgewall Software[\r]?)$$/\1\2-$(year)\4/g"
      769769
      770770update-copyright:
      771771ifeq "$(year)" ""

After the change is committed I'll update the copyright on 1.0-stable and 1.2-stable.

Last edited 4 years ago by Ryan J Ollos (previous) (diff)

comment:30 by Ryan J Ollos, 4 years ago

Updated copyright on 1.0-stable in r17305, on 1.2-stable in r17307.

Fixed lines containing CRLF not matched in r17306, merged in [17308:17310].

in reply to:  28 comment:31 by Ryan J Ollos, 4 years ago

Replying to Ryan J Ollos:

comment:27 change committed to 1.4-stable in r17292, merged to trunk in r17293.

In [17293#file36] I accidentally reverted a change r17290. This was fixed in r17328.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.