Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolved a to do by changing the year of the copyright to be dynamic #91

Merged
merged 20 commits into from
Nov 18, 2017

Conversation

shaneallcroft
Copy link
Contributor

Before this pull request, the copy right year was unchanging. With the code in this pull request implemented however, the year will change automatically as years change in real life.

Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I've noted two changes that will help it pass our testing.

@@ -19,7 +19,7 @@
from superflore.utils import resolve_dep
from superflore.utils import sanitize_string
from superflore.utils import trim_string

from time import gmtime, strftime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be above in the block with the other system imports (just below sys) And leave the white space here.

"""
ret = "# Copyright 2017 " + distributor + "\n"
ret = "# Copyright " + strftime("%Y", gmtime()) + distributor + "\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing whitespace after the year.

- # Copyright 2017Open Source Robotics Foundation
+ # Copyright 2017 Open Source Robotics Foundation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was caught by the testing but it shows that next year it will be a problem for the testing. The test will need to be extended with similar logic. It's hard coded to 2017 here: https://github.com/ros-infrastructure/superflore/blob/master/tests/ebuild/simple_expected.ebuild#L1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this feedback, I will get on changing these problems ASAP! :)

@allenh1
Copy link
Contributor

allenh1 commented Nov 14, 2017

Seems there's an unresolved merge conflict.

(https://github.com/shaneallcroft/superflore/blob/53f4d7d7e91ce0eb2bc5ac43934416dc11a34b87/superflore/generators/ebuild/ebuild.py#L15-L20)


@shaneallcroft It would also be good to update the test to be dynamic as well, since the year is hard coded (though that could be a separate PR, imo).

@@ -92,9 +98,8 @@ def get_ebuild_text(self, distributor, license_text):
Generate the ebuild in text, given the distributor line
and the license text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this blank line as well -- was there only to put a space between the comment and the TODO.

@allenh1
Copy link
Contributor

allenh1 commented Nov 15, 2017

@tfoote Do you think the test case should be a separate PR, or should it be addressed here?

@tfoote
Copy link
Member

tfoote commented Nov 15, 2017

It would be good to resolve here, otherwise it's a ticking time bomb, that will block development in the future.

@shaneallcroft
Copy link
Contributor Author

Gotcha, ty, I'll get on changing that tn :)

@shaneallcroft
Copy link
Contributor Author

Sorry for the delay, there was a school project that took alot longer than expected last night. Is test_simple the only test i need to touch in this case? No other tests I saw touched an ebuild file.

@shaneallcroft
Copy link
Contributor Author

wait damn it failed lemme check that out

@tfoote
Copy link
Member

tfoote commented Nov 17, 2017

You will probably need to change the example ebuild output to be templated on the year when loaded.

@shaneallcroft
Copy link
Contributor Author

Hmmmmm, I thought that's what I had just done, it's saying its failing because the text obtained from the file is empty, I may have just made a weird mistake. I might be able to fix it super easily. Gonna try now.

@shaneallcroft
Copy link
Contributor Author

shaneallcroft commented Nov 17, 2017

Also yes! :) looks like my change worked

expect_file.read(16)
fileUpdateStr = "# Copyright " + strftime("%Y", gmtime())
fileUpdateStr += expect_file.read()
expect_file.write(fileUpdateStr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't really want to write back to the file here.

I'd suggest loading the file and then using the python regex library sub function on the read data. https://docs.python.org/2/library/re.html#re.sub

it should be something like:

correct_text = re.sub('Copyright 2017', 'Copyright " + strftime("%Y", gmtime(), correct_text)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, gotcha, ty, I'll get on that

@@ -0,0 +1,24 @@
# Copyright 2017 Open Source Robotics Foundation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks to have been committed added by mistake?

@tfoote
Copy link
Member

tfoote commented Nov 17, 2017

Thanks this looks good now execpt the extra file #simple_expected.ebuild# is still in the changes.

@shaneallcroft
Copy link
Contributor Author

Sweet! & I'm on it

@shaneallcroft
Copy link
Contributor Author

Holy darn, I didn't even realize at first that the file in the PR changes was there just because it was a copy of simple_expected by another name, I thought the problem was the repo was thinking I made changes to simple_expected when I actually hadn't. Totally my B, I definitely should've realized that sooner haha, I think i may need some sleep soon 👍 the extraneous file mustve been created while I was testing the version of the ebuild test case that wrote to the file maybe? And then I accidentally git added it?

Regardless, I think everything is good to go now :) @tfoote and @allenh1 let me know if there's any more changes you guys want me to make for this PR before its merged. Thank you so much for the guidance on this!!!

@tfoote
Copy link
Member

tfoote commented Nov 17, 2017

The extra file's clear, but you rolled back the regex change too. It should be restored.

@tfoote
Copy link
Member

tfoote commented Nov 17, 2017

We should both get some sleep.

@shaneallcroft
Copy link
Contributor Author

Oh my gosh, how the heck did I even manage that??! ty for catching it.

And haha yeah we should definitely get some sleep. Thank you so much again for all your help. Have a goodnight! 👍 :)

Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good with a squash

Copy link
Contributor

@allenh1 allenh1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@allenh1 allenh1 merged commit 694ee98 into ros-infrastructure:master Nov 18, 2017
zffgithub pushed a commit to zffgithub/superflore that referenced this pull request Apr 11, 2023
…os-infrastructure#91)

* Resolved a todo by changing the year of the copyright to be dynamic

* Update test_ebuild.py to also be dynamic
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants