Advertisement:

Author Topic: Keeping track of code changes - best method?  (Read 1845 times)

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 845
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Keeping track of code changes - best method?
« on: March 19, 2019, 10:37:29 PM »
Can anyone suggest an efficient way of keeping track of changes done to smf files?

I'm thinking of just keeping track of what has been edited and why.
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline skb

  • Jr. Member
  • **
  • Posts: 333
    • Metabolically Challenged
Re: Keeping track of code changes - best method?
« Reply #1 on: March 19, 2019, 10:46:07 PM »
I use a (admin only) thread in which I record all the changes. New post for each change. I change the subject line every time to a more relevant / understandable / searchable one.
Learning, every day.
Forum - The Diabetic Pub
Because every diabetic needs help
SMF 2.1 RC2 (default theme) / TP 1.6.2

Online shawnb61

  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,168
    • sbulen on GitHub
Re: Keeping track of code changes - best method?
« Reply #2 on: March 19, 2019, 11:23:23 PM »
I've started my own local git repository. 

I hope to recreate all customizations/tweaks to little mods.  I want to get to the point where I can rebuild the forum completely via package manager. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 451
  • Gender: Female
Re: Keeping track of code changes - best method?
« Reply #3 on: March 20, 2019, 03:29:30 AM »
I always do the following:
1.  Insert a comment explaining what I've done and why and add my initials to the end of the line (I can then search a file for my initials);
2.  If the change came about as a result of something I read on this forum (or, very occasionally, somewhere else) I include the URL of the source of the information; and
3.  Keep a copy of the original line/lines of code as comments (very important for installing/uninstalling/reinstalling mods later on);

Here's an example from ./Sources/Load.php on one of my forums.
Quote
        // Fix for bug in Display Additional Membergroups on Profile mod. KL
        // See https://www.simplemachines.org/community/index.php?topic=141200.msg3031487#msg3031487
        //'list_additional_groups' => $profile['list_additional_groups'],
        'list_additional_groups' => !empty($profile['list_additional_groups']) ? $profile['list_additional_groups'] : '',

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,971
    • StoryBB/StoryBB on GitHub
Re: Keeping track of code changes - best method?
« Reply #4 on: March 20, 2019, 03:36:47 AM »
Git repository with build tools to automate syncing from local to server. (But I have multiple sites, multiple platforms and this lets me manage patching too, mostly.)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 845
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: Keeping track of code changes - best method?
« Reply #5 on: March 20, 2019, 07:03:22 AM »
Thanks all

GL700wing yep i agree with your method and that's great for individual code but I'd like to keep some master list so I easily know what files I've made manual edits to; as well.


Arantor & shawn Git repositories are well beyond me :)

skb yes but if the forum is down, so is that thread !



Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 451
  • Gender: Female
Re: Keeping track of code changes - best method?
« Reply #6 on: March 20, 2019, 07:41:31 AM »
GL700wing yep i agree with your method and that's great for individual code but I'd like to keep some master list so I easily know what files I've made manual edits to; as well.
Easy enough to do with a UNIX/Linux command ...

Quote
cd ~/www/forum ; find . \( -name \*php -o -name \*css \) -type f -exec grep -l KL {} \; | sort -f
./proxy.php
./Sources/Load.php
./Sources/LogInOut.php
./Sources/ManageMembers.php
./Sources/ManageSettings.php
./Sources/Memberlist.php
./Sources/PersonalMessage.php
./Sources/Post.php
./Sources/Profile-Modify.php
./Sources/Profile.php
./Sources/Subs-Graphics.php
./Sources/Subs-Post.php
./Sources/Subs.php
./Themes/default/Admin.template.php
./Themes/default/css/admin.css
./Themes/default/css/index.css
./Themes/default/Display.template.php
./Themes/default/GenericControls.template.php
./Themes/default/index.template.php
./Themes/default/languages/Admin.english-utf8.php
./Themes/default/languages/Admin.english.php
./Themes/default/languages/ManageSettings.english.php
./Themes/default/Login.template.php
./Themes/default/ManageMembers.template.php
./Themes/default/PersonalMessage.template.php
./Themes/default/Profile.template.php

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 845
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: Keeping track of code changes - best method?
« Reply #7 on: March 20, 2019, 09:30:58 PM »
I have no idea how that works or what it does....
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 451
  • Gender: Female
Re: Keeping track of code changes - best method?
« Reply #8 on: March 21, 2019, 04:59:06 AM »
I have no idea how that works or what it does....
That's OK - here's a PHP file that does the same thing.

1. Edit the file and change the value of $my_id to whatever string you use to identify your edits (eg, MKR).
2. Use the cPanel file manager to copy the file to the root/home directory/folder (ie, the same location where SSI.php and Settings.php reside) of each forum where you modify files.
3. To list the files where you've recorded details of edits open the MyFiles.php (eg, www.mywebsite.org/forum/MyFiles.php) and wait for it to display the results.



Here's the code ...

Quote
<?php
$my_id = "KL";
$this_dir = getcwd();
$command = "find . \( -name \*php -o -name \*css \) -type f -exec grep -liz $my_id\[\[:space:\]\] {} \; | sort -f";
$output = shell_exec($command);
echo "List of all .php and .css files containing string \"$my_id\" in $this_dir";
echo nl2br("\n\n$output\n");
echo "Finished listing .php and .css files containing string \"$my_id\" in $this_dir";
?>

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,587
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Keeping track of code changes - best method?
« Reply #9 on: March 21, 2019, 08:08:18 AM »
Git repository with build tools to automate syncing from local to server. (But I have multiple sites, multiple platforms and this lets me manage patching too, mostly.)

I feel that's too risky, b/c what if Github gets hacked or they change a setting (like Facebook as done in the past), where all your private information becomes public. I like the idea, but it's scary

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 50,589
Re: Keeping track of code changes - best method?
« Reply #10 on: March 21, 2019, 08:10:46 AM »
you can have a git repo without GitHub being involved.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,971
    • StoryBB/StoryBB on GitHub
Re: Keeping track of code changes - best method?
« Reply #11 on: March 21, 2019, 08:41:22 AM »
Indeed, I use my VPS for that. Others use Bitbucket, others use GitLab, Gerrit, or even just Git itself can be used that way with care.

I doubt Github will hit that problem, it’s not in Microsoft’s interest to let that happen.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Gwenwyfar

  • Great Wizard's familiar
  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 2,246
  • Gender: Female
    • Gwenwyfar on GitHub
Re: Keeping track of code changes - best method?
« Reply #12 on: March 21, 2019, 09:46:54 AM »
You could also have only a local repository. So it's essentially no different than having the files stored in your computer.

This is what I do, personally.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,971
    • StoryBB/StoryBB on GitHub
Re: Keeping track of code changes - best method?
« Reply #13 on: March 21, 2019, 09:57:51 AM »
I just have the master repository in my server so build tools can work with it and deploy things.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Gwenwyfar

  • Great Wizard's familiar
  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 2,246
  • Gender: Female
    • Gwenwyfar on GitHub
Re: Keeping track of code changes - best method?
« Reply #14 on: March 21, 2019, 10:04:26 AM »
Yeah, that sounds better. My setup isn't that elaborate. I still miss FireFTP auto-uploading things for me though.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,971
    • StoryBB/StoryBB on GitHub
Re: Keeping track of code changes - best method?
« Reply #15 on: March 21, 2019, 10:07:56 AM »
Yeah but I host a bunch of stuff.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 451
  • Gender: Female
Re: Keeping track of code changes - best method?
« Reply #16 on: March 21, 2019, 06:03:57 PM »
Yeah, that sounds better. My setup isn't that elaborate. I still miss FireFTP auto-uploading things for me though.
I'm still using FireFTP - I use a portable version of Firefox ESR and installed FireFTP as an unsigned add-on.

Alternatively, you could use Waterfox - FireFTP installs without the need to enable unsigned add-ons.

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 845
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: Keeping track of code changes - best method?
« Reply #17 on: March 27, 2019, 03:29:23 AM »
GL700 wing - thank you that's awesome !


You could also have only a local repository.

With a 1 Mbps (yep one megabit per second) download and 0.22 Mbps upload speed, no that doesn't work for me ROFL
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,971
    • StoryBB/StoryBB on GitHub
Re: Keeping track of code changes - best method?
« Reply #18 on: March 27, 2019, 03:56:33 AM »
Um, why not? A local repository sits on your computer...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,620
  • Gender: Male
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: Keeping track of code changes - best method?
« Reply #19 on: March 27, 2019, 04:10:14 AM »
You could also have only a local repository.

With a 1 Mbps (yep one megabit per second) download and 0.22 Mbps upload speed, no that doesn't work for me ROFL
no internet required
Try not to become a man of success, but rather try to become a man of value.
- Albert Einstein

Offline Looking

  • SMF Hero
  • ******
  • Posts: 2,324
  • SMF Customization
    • jeanborde on Facebook
    • SMF Custom Themes & Custom Coding
Re: Keeping track of code changes - best method?
« Reply #20 on: March 27, 2019, 05:34:00 AM »
I do the same as GL700Wing and also keep dated backups before major changes.

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 451
  • Gender: Female
Re: Keeping track of code changes - best method?
« Reply #21 on: March 27, 2019, 06:05:27 AM »
... also keep dated backups before major changes.
Ditto - plus I have a test forum with all the same Sources/Themes files where I stage and test *all* changes before making them on the production forum. 

Offline Gwenwyfar

  • Great Wizard's familiar
  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 2,246
  • Gender: Female
    • Gwenwyfar on GitHub
Re: Keeping track of code changes - best method?
« Reply #22 on: March 27, 2019, 08:04:55 AM »
Um, why not? A local repository sits on your computer...
And unless you're messing with attachments or avatars, most files are under a hundred kb, when you upload them to the forum server... Not that it even makes any difference compared to downloading backups or uploading packages to the forum... Even a full zip with all files doesn't go over some 5mb.

(Ps: My Internet has roughly the same rates...)

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 845
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: Keeping track of code changes - best method?
« Reply #23 on: March 28, 2019, 10:58:39 PM »
OK maybe I misunderstood local repository to mean FULL back up.

Does it just mean ' a copy of files I've changed ' ?
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,164
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: Keeping track of code changes - best method?
« Reply #24 on: March 29, 2019, 12:44:44 AM »
You would probably want a full mirror of your files, but that wouldn't be much to download once.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,971
    • StoryBB/StoryBB on GitHub
Re: Keeping track of code changes - best method?
« Reply #25 on: March 29, 2019, 03:40:10 AM »
OK maybe I misunderstood local repository to mean FULL back up.

Does it just mean ' a copy of files I've changed ' ?

No, it means a system designed to track every change made and let you leave yourself notes as to what changed and why.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 845
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: Keeping track of code changes - best method?
« Reply #26 on: March 29, 2019, 11:14:00 AM »
and that's what Im getting at - how best to structure such a system ?
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline Gwenwyfar

  • Great Wizard's familiar
  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 2,246
  • Gender: Female
    • Gwenwyfar on GitHub
Re: Keeping track of code changes - best method?
« Reply #27 on: March 29, 2019, 11:16:15 AM »
A local repository is the same as a github repository (or whichever other git repositories out there), except it is only in your computer, and not on the internet.

Online shawnb61

  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,168
    • sbulen on GitHub
Re: Keeping track of code changes - best method?
« Reply #28 on: March 29, 2019, 11:20:30 AM »
A 'repository' is all of the above.  A source code control system.  Repositories have a copy of the code as well as methods to regulate & track all of the changes.  More traditional source code control systems  (old school...) would have a 'checkout' function, like a library, to make sure folks' changes didn't conflict with each other; only one person was allowed to udpate a file at a time.  More modern source code controls systems (like Git) work at the 'commit' level - specific lines of code changed, "diffs" - which enable different folks to work on the same file concurrently (but have an added layer of complexity as a result for resolving the conflicts that will happen). 

Git is one of the more popular repositories in use today.  Using SMF 2.1 as an example, you have:
 - a copy of all the current source code: 
         https://github.com/SimpleMachines/SMF2.1/tree/release-2.1/Sources
 - a log of changes made: 
         https://github.com/SimpleMachines/SMF2.1/commits/release-2.1
 - with each detailed "commit" having specific changes made with notes as to why: 
         https://github.com/SimpleMachines/SMF2.1/pull/5545/files

Note that with Git, you do not have to use Github.com at all if you don't want to - you can have a local copy on your PC.  OR, you can have a private copy up on Github. 

Git is kinda complex, but extremely powerful.  Worth learning & using, IMO. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp