Skip to content

Instantly share code, notes, and snippets.

@loghound
Created October 25, 2010 04:46
Show Gist options
  • Save loghound/644419 to your computer and use it in GitHub Desktop.
Save loghound/644419 to your computer and use it in GitHub Desktop.
script to auto create version info
//
// LHSitemapVersionClass.h
// SiteMap
//
// Created by John McLaughlin on 6/24/10.
// Copyright 2010 Loghound.com. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface LHSitemapVersionClass : NSObject {
}
+(NSString*) scmVersionString ;
+(NSString*) buildNumber;
+(NSString*) pluginVersion;
@end
//
// LHSitemapVersionClass.m
// SiteMap
//
// Created by John McLaughlin on 6/24/10.
// Copyright 2010 Loghound.com. All rights reserved.
//
#import "LHSitemapVersionClass.h"
#import "version.h"
@implementation LHSitemapVersionClass
+(NSString*) scmVersionString {
return [NSString stringWithFormat:@"%s","Git checkin # "SVN_VERSION " hash: "GIT_HASH];
}
+(NSString*) buildNumber {
return [NSString stringWithFormat:@"Build: %d",BUILD_NUMBER];
}
+(NSString*) pluginVersion {
NSBundle *thisBundle=[NSBundle bundleForClass:self];
NSString *bundleVersion=[[thisBundle infoDictionary]valueForKey:@"CFBundleVersion"];
return bundleVersion;
}
@end
echo -n "note: Finding revision in "
pwd
revnum=`/usr/local/git/bin/git rev-list HEAD | /usr/bin/wc -l | sed -e 's/^ *//g;s/ *$//g'`
fullrevnum=`/usr/local/git/bin/git rev-parse HEAD`
buildNumber=`grep -e "BUILD_NUMBER " version.h | grep -o "[0-9].*"`
let buildNumber=$buildNumber+1
# Now write the constant declaration to the file:
echo "#define SVN_VERSION \"$revnum\"" > version.h
echo "#define GIT_HASH \"$fullrevnum\"" >> version.h
echo "#define SVN_VERSION_NUM $revnum" >> version.h
echo "#define BUILD_NUMBER $buildNumber" >> version.h
echo "note: Wrote revision $revnum to version.h"
#import "version.h"
#import "version_h.h"
#include <stdio.h>
static char version[]="Git checkin # "SVN_VERSION " hash: "GIT_HASH;
void printVersion() {
fprintf(stderr,"%s",version);
}
char *versionString() {
return version;
}
void printVersion();
char *versionString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment