首页 \ 问答 \ 我如何知道在github上分配了我的回购(How can I tell who forked my repository on GitHub?)

我如何知道在github上分配了我的回购(How can I tell who forked my repository on GitHub?)

有没有办法知道谁在GitHub上分配了我的回购 我可以看到叉子的数量,但是我也想知道谁分配了我的回购,还有什么样的改变。 我知道如果他们有兴趣回馈给我的回购,他们可以给我一个拉动请求,有没有其他方法可以找出我们的所有人分了我的回购?


Is there a way to know who has forked my repository on GitHub? I can see the number of forks, but I'd like to know who forked my repository and what kind of changes they made to it.

I know they can send me a pull request if they're interested in contributing back to my repository, but is there some other way for me to find out who forked my repository?


原文:https://stackoverflow.com/questions/12208450
更新时间:2023-01-16 17:01

最满意答案

是的,你可以这样使用instance_variable_get

class Hello
  def method1
    @hello = "pavan"
  end
end

h = Hello.new
p h.instance_variable_get(:@hello) #nil
p h.method1                        #"pavan" - initialization of @hello
p h.instance_variable_get(:@hello) #"pavan"

如果变量未定义(在我的示例中首先调用instance_variable_get ),则nil


安德烈在他的评论中提到:

您不应该将其作为默认方式访问实例变量,因为它违反封装。

更好的方法是定义一个访问器:

class Hello
  def method1
    @hello = "pavan"
  end
  attr_reader :hello  
end

h = Hello.new
p h.hello #nil
p h.method1                        #"pavan" - initialization of @hello
p h.hello #"pavan"

如果您想要另一个方法名称,可以将访问器alias :my_hello :hello

并且如果类没有在您的代码中定义,而是在一个gem中:您可以修改代码中的类并将新的函数插入到类中 。


Yes, you can use instance_variable_get like this:

class Hello
  def method1
    @hello = "pavan"
  end
end

h = Hello.new
p h.instance_variable_get(:@hello) #nil
p h.method1                        #"pavan" - initialization of @hello
p h.instance_variable_get(:@hello) #"pavan"

If the variable is undefined (first call of instance_variable_get in my example) you get nil.


As Andrew mention in his comment:

You should not make this the default way you access instance variables as it violates encapsulation.

A better way is to define an accessor:

class Hello
  def method1
    @hello = "pavan"
  end
  attr_reader :hello  
end

h = Hello.new
p h.hello #nil
p h.method1                        #"pavan" - initialization of @hello
p h.hello #"pavan"

If you want another method name, you could alias the accessor: alias :my_hello :hello.

And if the class is not defined in your code, but in a gem: You can modify classes in your code and insert new functions to classes.

相关问答

更多
  • 是的,你可以这样使用instance_variable_get : class Hello def method1 @hello = "pavan" end end h = Hello.new p h.instance_variable_get(:@hello) #nil p h.method1 #"pavan" - initialization of @hello p h.instance_variable_get(:@hello) #"pa ...
  • 您正在访问已在堆栈中分配的块,该块不再在范围内。 您需要将bb分配给复制的块。 应该将bb移动到类的实例变量中。 //Do not forget to Block_release and nil bb on viewDidUnload bb = Block_copy(bb); You are accessing the block which was allocated on the stack which is no longer in scope. You need to assign bb to t ...
  • 这意味着这是允许的: public class Test { public int instanceVariable = 42; public void instanceMethod() {System.out.println("Hello!");} public static void staticMethod() { Test test = new Test(); System.out.println(test.instanceVariable ...
  • 在当前代码中,您将在Test 类上定义实例变量,而不是在Test的实例上定义。 也就是说,您可以使用类方法访问它: class Test @state = 4 def self.state @state end end # Test.state # => 4 但这不是你想要的; 你不希望这个值存在于你的类中,你希望它存在于你的类的每个实例中。 要在类的实例上初始化实例变量,您应该提供一个构造函数: class Test attr_accessor :state def i ...
  • 使用您编辑过的MCVE: 在get_val方法中设置self.MCVE = classA()时,您将MCVE设置为classA的新实例 。 因此,对classA的某个其他实例的row_num属性的任何修改都是无关紧要的。 例如, classA().define()正在为完全不同的类实例修改row_num属性。 它的row_num是一个实例变量,仅为该特定实例定义。 如果您希望row_num属性在所有classA实例中保持classA ,您可能希望将其设置为类变量,就像这样(尽管是一个无意义的例子)。 cla ...
  • Getter方法,因为它更容易重构。 假设您要在访问时更新时间戳。 class Test def user @user.last_read = Time.now @user end end 并且所有对user的引用都使用新逻辑进行更新。 如果你的参考是@user , @user不那么容易了。 Getter method, because it's easier to refactor. Say you want to update a time stamp at the point ...
  • 为了评估局部变量,您需要传入字符串“local_var”,它将返回局部变量的值。 根据我对文档的解释,如果传入一个块,则无法传入参数。 块形式中实例eval的行为是作为闭包访问该调用所在的对象的实例变量和私有方法。 带参数的实例eval的行为允许您评估该调用范围内的字符串。 After some search and advices from my friend i think i figured out the problem. In ruby there is two Context when your ...
  • 您可能能够做的最接近的事情是使用单例实例变量上的ThreadStatic属性。 这将在访问方面保持静态语义,但每个线程都有自己的实例。 public class ThreadStaticSingleton { [ThreadStatic] private static ThreadStaticSingleton instance; public static ThreadStaticSingleTon Instance { get { ...
  • 你可以使用“super”来调用父类初始化块并定义实例变量“@var”。 在这种情况下,您可以为另一个实例修改此实例变量的值。 喜欢这个: class Shape def initialize () @var = "woohoo" end end class Rectangle < Shape def initialize(l, w) @length = l @width = w super() end def area() print @var ...
  • 我不认为你可以用当前的代码。 您的jQuery ajax超出了上下文范围,也就是说,您从客户端触发ajax,并且服务器使用=> format.json {render :json => @markers}返回一些数据,因此从服务器返回的数据将可供您使用在你完成回调就像你已经完成。 你可以做两件事 从可以访问实例变量的操作中渲染部分内容 def index # Logic here render :partial => "locations/location_results" end 或者您可以为 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)