generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check SHA1 hashes for blobs locally (#55)
* Check SHA1 hashes for blobs locally Fixes #53 * Adding functional test * Realized I was trying to hash the encoded contents * Turns out git prefixes the file and then hashes it * Let's try that again * Debugging * 🤦 * Fine I just won't use if * I don't know anymore
- Loading branch information
1 parent
6a812aa
commit cffb18a
Showing
5 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {createHash} from 'crypto'; | ||
|
||
/** | ||
* Compute the git blob hash for a base64 encoded string | ||
* @param b64string Base64 encoded string | ||
*/ | ||
export function computeBlobHashB64String(b64string: string): string { | ||
const contents = Buffer.from(b64string, 'base64'); | ||
const buf = Buffer.concat([Buffer.from(`blob ${contents.length}\0`), contents]); | ||
const hasher = createHash('sha1'); | ||
return hasher.update(buf).digest('hex'); | ||
} |