@@ -5,29 +5,6 @@ use std::fs;
5
5
use std:: path:: { Path , PathBuf } ;
6
6
use std:: process:: Command ;
7
7
8
- fn codspeed_go_version ( ) -> anyhow:: Result < String > {
9
- if std:: env:: var ( "CODSPEED_LOCAL_GO_PKG" ) . is_err ( ) && cfg ! ( not( test) ) {
10
- return Ok ( format ! ( "v{}" , env!( "CARGO_PKG_VERSION" ) ) ) ;
11
- }
12
-
13
- // When running in GitHub Actions, we always want to use the latest
14
- // codspeed-go package. For this, we have to use the current branch.
15
- if std:: env:: var ( "GITHUB_ACTIONS" ) . is_ok ( ) {
16
- return Ok ( std:: env:: var ( "GITHUB_HEAD_REF" ) ?) ;
17
- }
18
-
19
- // Locally, run `git rev-parse --abbrev-ref HEAD` to get the current branch name
20
- let output = Command :: new ( "git" )
21
- . args ( [ "rev-parse" , "--abbrev-ref" , "HEAD" ] )
22
- . output ( )
23
- . context ( "Failed to execute 'git rev-parse' command" ) ?;
24
- if !output. status . success ( ) {
25
- let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
26
- bail ! ( "Failed to get current git branch: {}" , stderr) ;
27
- }
28
- Ok ( String :: from_utf8_lossy ( & output. stdout ) . trim ( ) . to_string ( ) )
29
- }
30
-
31
8
pub fn replace_pkg < P : AsRef < Path > > ( folder : P ) -> anyhow:: Result < ( ) > {
32
9
let codspeed_root = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . parent ( ) . unwrap ( ) ;
33
10
let replace_arg = format ! (
@@ -78,10 +55,9 @@ pub fn patch_imports<P: AsRef<Path>>(
78
55
debug ! ( "Patched {patched_files} files" ) ;
79
56
80
57
// 2. Update the go module to use the codspeed package
81
- let pkg = format ! (
82
- "github.com/CodSpeedHQ/codspeed-go@{}" ,
83
- codspeed_go_version( ) ?
84
- ) ;
58
+ let version = std:: env:: var ( "CODSPEED_GO_PKG_VERSION" )
59
+ . unwrap_or_else ( |_| format ! ( "v{}" , env!( "CARGO_PKG_VERSION" ) ) ) ;
60
+ let pkg = format ! ( "github.com/CodSpeedHQ/codspeed-go@{}" , version) ;
85
61
debug ! ( "Installing {pkg}" ) ;
86
62
87
63
let mut cmd: Command = Command :: new ( "go" ) ;
0 commit comments