Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/thunil/ofblend
22 June 2024, 15:59:02 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    • 5172513a0ad16394cb72461ef00d5a9471145fe1
    No releases to show
  • f24db56
  • /
  • tools
  • /
  • getGitVersion.py
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:31141706759874e757474c06e5d7ced64bee4d17
origin badgedirectory badge
swh:1:dir:1113e3d01a6d77906534d3119ad96ef2f66bf176
origin badgerevision badge
swh:1:rev:5172513a0ad16394cb72461ef00d5a9471145fe1
origin badgesnapshot badge
swh:1:snp:92b35bd5e6b77376ffd5ff2ac1643b476f31eba4

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 5172513a0ad16394cb72461ef00d5a9471145fe1 authored by Nils Thuerey on 08 June 2017, 20:31:03 UTC
Create README.md
Tip revision: 5172513
getGitVersion.py
#!/usr/bin/python
import os
import shutil
import sys
import re
doDebug = False

# helper function to write output file
def writeHeader( filename, content ):
	try:
		outfile = open(filename, "w")
		outfile.write( content )
		outfile.close()
		if(doDebug):
			print( "Wrote '" + filename +"' " )
	except IOError:
		print("Warning, unable to write file '"+filename+"' ")
		exit(1)

dummyContent = "\n// could not determine git version\n\n"

# params

if len(sys.argv)<2:
	print("Usage makeHgVersion.py <out-file> <optional: path-to-git-exe> ")
	print("Warning, the target file <out-file> will be overwritten! ")
	exit(1)

# target file
outname = sys.argv[1]

# path to git executable, try a few options
# note /opt/local/bin/xxx is a double entry, can be overwritten by command line arg
exenames = [ "--replace--", "--replace--", "/opt/local/bin/git", "/usr/local/bin/git" ]
# check default
exenames[1] = os.popen("which git").read() 
exenames[1] = exenames[1].rstrip('\n')
# optionally, make argument
if len(sys.argv)>2:
	exenames[0] = sys.argv[2]

exename = ""
for nameCheck in exenames:
	#print "exe entry '"+nameCheck+"' "  # debug
	if( os.path.isfile(nameCheck) ):
		exename = nameCheck

# write empty file if no exe found
if(exename == ""):
	writeHeader( outname, dummyContent )
	print("Warning, no exe found - writing dummy header")
	exit(0); # dont throw an error for make, we can still continue...

if(doDebug):
	print("Params: outname '"+outname+"' , exename '"+exename)

# read old contents
oldContent = ""
doWrite    = True
try:
	infile = open(outname, "r")
	oldContent = infile.read()
	infile.close()
	if(doDebug):
		print("\n Old file content '"+oldContent+"' end \n")
except IOError:
	if(doDebug):
		print("Old file not found...")


# get git version
#gitVersion = os.popen(exename+" id").read() 
# get gid id
gitVersion = os.popen(exename+" log -1 ").read() 
# remove newlines...
if len(gitVersion)>0:
	gitVersion = gitVersion.splitlines()[0]
	gitVersion = gitVersion.rstrip('\n')
else:
	# probably git error, no repo or so; init default
	writeHeader( outname, dummyContent )
	print("Warning, git info failed - writing dummy header")
	exit(0)

if(doDebug):
	print( "Got git info: '" + gitVersion +"' " )

# matches old?
newContent = "\n\n#define MANTA_GIT_VERSION \"" + gitVersion + "\" \n\n" 

if(newContent == oldContent):
	if(doDebug):
		print("MATCHES! No write")
	doWrite = False
else:
	if(doDebug):
		print("Old info different, writing")

# write temp file
if(doWrite):
	writeHeader( outname, newContent )
	print( "Updated repository info header , "+gitVersion )


back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API