@@ -21,6 +21,7 @@ func init() {
2121 RunE : runWho ,
2222 }
2323 cmd .Flags ().IntP ("number" , "n" , 5 , "Number of contributors to show" )
24+ cmd .Flags ().String ("since" , "" , "Only consider contributions after this date (e.g., 6months, 2024-01-01)" )
2425 cmd .Flags ().Bool ("no-limit" , false , "Remove the 200-file cap for directory analysis" )
2526 rootCmd .AddCommand (cmd )
2627}
@@ -32,9 +33,10 @@ func runWho(cmd *cobra.Command, args []string) error {
3233 }
3334
3435 n , _ := cmd .Flags ().GetInt ("number" )
36+ since , _ := cmd .Flags ().GetString ("since" )
3537
3638 if len (args ) == 0 {
37- return whoRepo (n )
39+ return whoRepo (n , since )
3840 }
3941
4042 path := args [0 ]
@@ -45,9 +47,9 @@ func runWho(cmd *cobra.Command, args []string) error {
4547 }
4648 if info .IsDir () {
4749 noLimit , _ := cmd .Flags ().GetBool ("no-limit" )
48- return whoDir (path , n , noLimit )
50+ return whoDir (path , n , since , noLimit )
4951 }
50- return whoFile (path , n )
52+ return whoFile (path , n , since )
5153}
5254
5355// --- File-level: git blame (fast, ~100ms per file) ---
@@ -59,10 +61,15 @@ type blameAuthor struct {
5961 lastDate string
6062}
6163
62- func whoFile (path string , n int ) error {
64+ func whoFile (path string , n int , since string ) error {
6365 sp := ui .StartSpinner (fmt .Sprintf ("Analyzing %s..." , path ))
6466
65- out , err := git .Run ("blame" , "--line-porcelain" , path )
67+ blameArgs := []string {"blame" , "--line-porcelain" }
68+ if since != "" {
69+ blameArgs = append (blameArgs , "--since" , since )
70+ }
71+ blameArgs = append (blameArgs , path )
72+ out , err := git .Run (blameArgs ... )
6673 if err != nil {
6774 sp .Stop ()
6875 ui .PrintError (fmt .Sprintf ("Failed to blame %s: %s" , path , err ))
@@ -145,7 +152,7 @@ func whoFile(path string, n int) error {
145152
146153// --- Directory-level: concurrent blame across files ---
147154
148- func whoDir (dir string , n int , noLimit bool ) error {
155+ func whoDir (dir string , n int , since string , noLimit bool ) error {
149156 sp := ui .StartSpinner (fmt .Sprintf ("Analyzing %s..." , dir ))
150157
151158 filesOut , err := git .Run ("ls-files" , dir )
@@ -192,7 +199,12 @@ func whoDir(dir string, n int, noLimit bool) error {
192199 sem <- struct {}{}
193200 defer func () { <- sem }()
194201
195- out := git .RunUnchecked ("blame" , "--line-porcelain" , f )
202+ bArgs := []string {"blame" , "--line-porcelain" }
203+ if since != "" {
204+ bArgs = append (bArgs , "--since" , since )
205+ }
206+ bArgs = append (bArgs , f )
207+ out := git .RunUnchecked (bArgs ... )
196208 counts := map [string ]int {}
197209 emails := map [string ]string {}
198210 var name , email string
@@ -284,10 +296,14 @@ func whoDir(dir string, n int, noLimit bool) error {
284296
285297// --- Repo-level: git shortlog (fast, commits only) ---
286298
287- func whoRepo (n int ) error {
299+ func whoRepo (n int , since string ) error {
288300 sp := ui .StartSpinner ("Analyzing contributors..." )
289301
290- out , err := git .Run ("shortlog" , "-sne" , "HEAD" )
302+ args := []string {"shortlog" , "-sne" , "HEAD" }
303+ if since != "" {
304+ args = append (args , "--since=" + since )
305+ }
306+ out , err := git .Run (args ... )
291307 sp .Stop ()
292308 if err != nil || out == "" {
293309 ui .PrintInfo ("No contributors found." )
0 commit comments