Hey guys,
I've built applications and I've always wanted my own version and build number that's more like bigger applications.
Requirements:
1. The version should be manual (besides obviously there is no way for the app itself to know if it got a new feature vs a fix, I'd like to be the one starting new versions or sub-versions)
2. Build number should be automatic based on the most recently modified file.
My Idea:
1. Get all the project files and find the most recent file update time stamp
2. Calculate the build number based on given version number to get a value that's from hundreds to thousands long (I don't want to reach tens of thousands preferably)
I'm having trouble with the math for 2. Primarily how I can make the build look like it was reset when I change version number, say when I change the version value from 2.0.1 to 2.0.2 or 2.1.0
Maybe I should just store the date the version was changed when change the version value itself and calculate the number of hours from that TS (time stamp) and the last modified file TS.
I'm open to any other ideas.
Peace out,
Dan
5 5653
current test code I'm playing around with: -
-
-
<?php
-
-
-
-
/**
-
* Gets entire file system recursively or non-recursivly in a given directory
-
*
-
* @param mixed $directory
-
* @param mixed $recursive
-
* @return array
-
*/
-
function getAllFiles($directory, $recursive = true)
-
{
-
$result = array();
-
-
if(is_dir($directory))
-
{
-
$handle = opendir($directory);
-
while ($datei = readdir($handle))
-
{
-
if (($datei != '.') && ($datei != '..')) {
-
$file = $directory.$datei;
-
if (is_dir($file)) {
-
if ($recursive) {
-
$result = array_merge($result, getAllFiles($file.'/'));
-
}
-
}
-
else {
-
$result[] = $file;
-
}
-
}
-
}
-
closedir($handle);
-
}
-
-
return $result;
-
}
-
-
/**
-
* Gets the most recent file TS in a directory
-
*
-
* @uses getAllFiles()
-
* @param mixed $directory
-
* @param mixed $recursive
-
* @return integer
-
*/
-
function getHighestFileTimestamp($directory, $recursive = true)
-
{
-
$allFiles = getAllFiles($directory, $recursive);
-
-
$highestKnown = 0;
-
foreach ($allFiles as $val)
-
{
-
$currentValue = filemtime($val);
-
if ($currentValue > $highestKnown) $highestKnown = $currentValue;
-
}
-
-
return $highestKnown;
-
}
-
-
-
/**
-
* Makes a build number based on newest file in the project and project version
-
* @uses getHighestFileTimestamp()
-
* @return integer
-
*/
-
function makeBuildNumber($version,$dir)
-
{
-
$newestFileTS = getHighestFileTimestamp($dir,true);
-
-
// TS is too large, subtract and version number + padding in thousands to get a build number
-
$verMx = intval(preg_replace('/[^0-9]/','',$version)) + 1257455304 * 1000;
-
-
return ($newestFileTS - $verMx);
-
}
-
-
echo makeBuildNumber("2.0.1","/path/to/project/");
-
-
see if you can get a better formula to work for line number 74 above.
Dan
My best idea so far:
Build number is based on the 3rd version value. So when you change from 2.0.1 to 2.0.5 the build number grows as well. But will seem to have reset when you change to 2.0.1
psuedocode: -
-
$version = "2.0.2";
-
$multiplier = end(explode(".",$version)) * $othervalues;
-
-
ya? no? got a better idea?
Dan
@dlite922
I’d use the subversion (or whatever you use) revision number as build number.
@Dormilich
How would I display that on the main page of the app though? Every time I check anything into SVN i'd have to change the version number by hand, which is daily at the beginning phases of the project.
It would be cool if SVN would update a text file everytime you checked something in and I could read the file content.
Dan
the latest revision number should be somewhere in .svn.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Whitney Kew |
last post by:
Hi,
Is there a programmatic way to get the "general" or "overall" version of a
currently running instance of the Visual Studio .NET compiler? What I mean
by "general" or "overall" version is, I...
|
by: Sonoman |
last post by:
Hi all:
I am trying to write a simple program that simulates asking several persons
their birth day and it counts how many persons are asked until two have the
same birth day. The problem that I...
|
by: Wahoo |
last post by:
Another question,my teacher gave me a code for
generate a random number from 1 - range, but I can't made it work, where is
the problem?
Thanks!!
|
by: Joe |
last post by:
Hi, I have been working on some code that requires a high use of random
numbers within. Mostly I either have to either:
1) flip a coin i.e. 0 or 1, or
2) generate a double between 0 and 1.
I...
|
by: Djakobsson |
last post by:
Hi,
I have a SQL server DB for a document handeling system.
For the new version of the system the database have been updated with
some new tables, new stored procedures and updated stored...
|
by: mekim |
last post by:
Hello....I am trying to System.Reflection.Assembly.GetExecutingAssembly
().GetName
().Version.ToString () ;
to display the version of the app...but it remains static and therefore does
not...
|
by: John |
last post by:
Hi
How can I change the product version number that is returned by
Application.ProductVersion?
Thanks
Regards
|
by: Gavin Sullivan |
last post by:
I've been using the date (in YMMDD) format for the build number in the
AssemblyVersion attribute. However, it appears that numbers 65534 are
invalid!! Bit of a bummer for 2007!!!
Is there a...
|
by: ewingate |
last post by:
I cannot seem to get the version number of my VB app to increment
properly in VS2005. When I build the app each day the "build" number
increments with no problem as does the version number but if I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |